-2
Python GUIを作成しましたが、今では変数に参照と総コストをファイルに保存したいと思います。
どうすれば実現できますか?以下の結果をPythonでファイルに書き出す方法/結果を保存するには?
は次のようにファイルの書き込みをしようとしたことがあり:
def writetofile():
import os
outputname ='tutorial.txt'
a= "TotalCost"
myfile = open(outputname,'w')
myfile.write('File A value is : ' + str(a) + '\n')
myfile.close()
if os.stat(outputname).st_size > 0:
print("tutorial.txt file has been populated")
else:
print("the output value is empty")
print("The A value should read: " + str(a) + '\n')
writetofile()
だけテキストは文字列ではなく、計算されたのですにtotalCost