Python Praw TypeError: not all arguments converted during string formatting

Python Praw TypeError: not all arguments converted during string formatting

我之前 运行 编写脚本时没有收到此消息...现在我收到了。我错过了什么?

comments.reply("__%s__","\n","Current Temp: %s\u00b0F" % (str(cityname),temp_f))

问题出在第三个字符串:

"Current Temp: %s\u00b0F" % (str(cityname),temp_f)

它只包含一个格式说明符%s,但包含一个二元组作为格式化参数。因此,并非所有参数都可以在格式化期间进行转换。另一方面,您的第一个字符串 __%s__ 未格式化,所以我觉得您宁愿将这三个字符串组合起来(例如,省略逗号):

comments.reply("__%s__\nCurrent Temp: %s\u00b0F" % (cityname, temp_f))