python: TypeError: %c requires int or char



。。。但是"%c"根本不在我的脚本中。

Traceback (most recent call last):
  File "./build_SoS.py", line 88, in <module>
    if int(locID) == int(2501): print " 20% complete with year %s" % str(yr)
TypeError: %c requires int or char

早些时候,我得到了"无符号字节整数大于最大值",但不是每一次,也不是这次。不确定发生了什么。

感谢

您没有"%c",但您有"%c"。

在您的格式字符串(即%运算符的左手边(中,您需要使用另一个%字符转义%字符(显示在"20%"中(。

print " 20%% complete with year %s" % str(yr)

最新更新