Изменены data.txt, script.py
This commit is contained in:
parent
05f0a87bd9
commit
d7f0d26e66
14
script.py
14
script.py
@ -0,0 +1,14 @@
|
||||
import re
|
||||
|
||||
with open("data.txt", 'r', encoding="UTF-8") as f:
|
||||
text = f.read()
|
||||
|
||||
words = re.findall(r'\b\w+\b', text)
|
||||
print(words)
|
||||
|
||||
sorted_words = sorted(words, key=len)
|
||||
|
||||
with open("output.txt", "+w", encoding="UTF-8") as f:
|
||||
for word in sorted_words:
|
||||
print(word)
|
||||
f.write(word + "\n")
|
||||
Loading…
Reference in New Issue
Block a user