当询问他们的储蓄和存款时,我试图在用户输入中添加一个美元符号(“$”)。在我的脚本结束时,我正在创建一个包含所有信息的文本文件,但我希望在创建文件时数字前面有符号。
savings = int(input("How much money do you have in your savings: ")
deposits = int(input("How much money do you put in deposits: ")
from tabulate import tabulate
table = tabulate([["Name", "Last", "Age", "Company", "Hourly Rate", "Occupation", "Savings", "Deposits"],
[(name), (last_name), (age), (company), (hourly_rate), (occupation), (savings, + "$"), (deposits)]], headers = "firstrow")
我已将 +"$" 添加到 Savings 变量中,因为我认为这会起作用,但后来我会收到此错误:
TypeError: bad operand type for unary +: 'str'
所以总而言之,即使创建了文本文件,我也只希望它具有美元符号,因为这是它现在看起来的示例:
储蓄存款
9000 900 <----缺少美元符号
我希望这是有道理的。谢谢你。