python中运算符的字符串格式错误
使用Python字符串格式,我的预期输出是:python中运算符的字符串格式错误,python,string,formatting,Python,String,Formatting,使用Python字符串格式,我的预期输出是: If you took 19 and 13 and added them, you would get 22 但是我不太确定我是否做得很好。我不断地发现这个错误: Not all arguments converted during string formatting 你能帮忙吗 代码: 您只是缺少字符串中最后%后面的最后一个's' print "If you took %s and %s and added them, then you wi
If you took 19 and 13 and added them, you would get 22
但是我不太确定我是否做得很好。我不断地发现这个错误:
Not all arguments converted during string formatting
你能帮忙吗
代码:
您只是缺少字符串中最后%后面的最后一个's'
print "If you took %s and %s and added them, then you will get %s" %(my_age,teenager,my_age + teenager)
在上次
%%
之后缺少说明符。您需要:“获取%d”
@TKA如果您得到想要的答案,请不要忘记单击复选标记。如果答案是有帮助的,但不完全正确,礼貌的做法是竖起大拇指表示感谢。
print "If you took %s and %s and added them, then you will get %s" %(my_age,teenager,my_age + teenager)