1. 程式人生 > >python 將print輸出儲存到文字檔案中

python 將print輸出儲存到文字檔案中

print輸出到文字

import sys



print 'HEO=LLO'
output=sys.stdout
outputfile=open("D:\\DEM4\\2.txt","a")

sys.stdout=outputfile

中文輸出新增

type = sys.getfilesystemencoding()#python編碼轉換到系統編碼輸出