Обновить script.py
This commit is contained in:
parent
1a1f27f535
commit
6510c4643f
27
script.py
27
script.py
@ -1,24 +1,5 @@
|
||||
with open("data.txt", "r", encoding="utf-8") as file:
|
||||
lines = file.readlines()
|
||||
with open("data.txt", "r", encoding="utf-8") as infile:
|
||||
lines = infile.readlines()
|
||||
|
||||
numbers = []
|
||||
words = []
|
||||
|
||||
for line in lines:
|
||||
line = line.strip()
|
||||
if line.isdigit():
|
||||
numbers.append(line)
|
||||
else:
|
||||
words.append(line)
|
||||
|
||||
|
||||
with open("output.txt", "w", encoding="utf-8") as output_file:
|
||||
output_file.write("Слова:\n")
|
||||
for word in words:
|
||||
output_file.write(word + "\n")
|
||||
|
||||
output_file.write("\nЧисла:\n")
|
||||
for number in numbers:
|
||||
output_file.write(number + "\n")
|
||||
|
||||
print("Файл output.txt успешно создан!")
|
||||
with open ("output.txt" ,"w" encoding="utf-8" as outfile:
|
||||
outfile.writelines(transformed_data)
|
||||
|
Loading…
Reference in New Issue
Block a user