+ 1
How to sort a text file.txt in python?
a = f open("file.txt", r) a.split Sort?
2 Antworten
+ 1
Ok, thank
I can try it
0
When you handle a file you need to open, handle and close it. You can use:
file = open("file.txt", "r")
text = file.read()
file.close()
After that you can handle variable text like any string:
print(sorted(text.split()))