python新手,需要将此数据存储到文本文件中。主要是我的记录,但在 recsave.write 行中出现了 concat 错误(元组)。任何帮助或建议,或者只是做错了
print (' Title ')
name = 'y'
while name == 'y':
print (' Enter the name of the sender: ')
sender = input("\n")
# add name of reciever #
print (' Enter the name of the reciever: ')
reciever = input("\n")
# how much would you like to send #
print (' How much would you like to send :$ ')
amount = input("\n")
record = (sender, 'sent :$',amount, 'to', reciever, "\n" )
recsave = open('Transaction History.txt', 'w')
recsave.write(record + '\n')
recsave.close()
print (str(record, "\n"))
name = input (' Are there anymore transactions? ( Enter y or n ): ')
想在打开文本文件时得到它。你得到
name 发送 $amount 给 name
还需要包括时间戳:(每次循环运行时都会将每个循环保存到记录中
一只斗牛犬
相关分类