python 如何将代码中的输入保存到txt里边
生活随笔
收集整理的這篇文章主要介紹了
python 如何将代码中的输入保存到txt里边
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
一、在 print 前建立一個txt
python3:
f = open('print.txt', 'w') print('this is a txt', file = f) f.close()python2:
f = open('print.txt', 'w') print>>f, 'this is a txt' f.close()二、在控制臺輸入
python print_txt.py > print.txt總結
以上是生活随笔為你收集整理的python 如何将代码中的输入保存到txt里边的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python如何读取文件夹下的子文件夹
- 下一篇: xls文件怎么转成xlsx文件