我想在python中增加货币的价值。我在用语言环境.货币创建格式,我把它放在一个变量中。我想打印要添加的变量+值以生成新值。你知道吗
import locale
locale.setlocale( locale.LC_ALL, '' )
'English_United States.1252'
while True:
print("Welcome! Get ur pet here!")
pet = input("Would you like a dog, cat, or fish:").lower()
d = (" __ \n (___()'`;\n /, /` \n \\\\'--\\\ ")
money = (locale.currency( 25 ))
if pet == "dog":
print(money) #I've done (money + 10) There is no error message, but
#I want it to add 10 to 25 and it doesn't do that.
print(d)
local.curency
返回一个字符串。你不能给它增加价值。你知道吗您必须将货币存储为整数,并仅在打印时使用
local.curency
对其进行格式化。你知道吗相关问题 更多 >
编程相关推荐