我找到了一个解决方案,用于写入打印到屏幕的内容......
import sys
global saveFile
saveFile = open((fileName)+'.txt','w')
sys.stdout = saveFile
print("THIS QUOTE HAS BEEN BROUGHT TO YOU BY 'PAINTED'.")
print("Customer ID:", fileName)
print("Total Wall Area:", format(WallArea, '.2f'), "m²")
print("Total Window Area:", format(WindowArea, '.2f'), "m²")
print("Total Door Area:", format(DoorArea, '.2f'), "m²")
print("Overall Paint Area:", format(PaintArea, '.2f'), "m²")
print("At £", format(costPer, '.2f'), "Per Square Metre.")
print("Final Quote Price: £", format(FinalPrice, '.2f'), "Plus VAT")
saveFile.close()
因此它创建了我想要的文件并将所有数据写入其中但现在它不会在控制台中打印以供用户查看?如何将其打印到屏幕和写入文件。