Obtenez du texte à partir du fichier txt python
with open ("data.txt", "r") as myfile:
data = myfile.read().splitlines()
TheProgrammer
with open ("data.txt", "r") as myfile:
data = myfile.read().splitlines()
# where f is the file alias
with open(r"path\to\file.txt", encoding='UTF8') as f:
contents = f.read()
print(contents)
with open('the-zen-of-python.txt') as f:
for line in f:
print(line)
Code language: JavaScript (javascript)