“Python сохранить вывод для файла” Ответ

Как записать в выходной файл в питании

#first arg is the name of the file
#second arg notes that the file is open to write to it
outputFile = open("fileName", "w")
#next line writes to the file
outputFile.write(str)
#remember to close opened files
outputFile.close()
NitroPog

Печать вывода Python для файла

print("Hello stackoverflow!", file=open("output.txt", "a"))
print("I have a question.", file=open("output.txt", "a"))
Jolly Jellyfish

Python сохранить вывод для файла

with open("output.txt", "a") as f:
    print("Hello StackOverflow!", file=f)
    print("I have a question.", file=f)
Inexpensive Ibis

Сохранить вывод Python в текстовый файл

$ python my_program.py > output.txt
Marton

Ответы похожие на “Python сохранить вывод для файла”

Вопросы похожие на “Python сохранить вывод для файла”

Больше похожих ответов на “Python сохранить вывод для файла” по Python

Смотреть популярные ответы по языку

Смотреть другие языки программирования