gpt4 book ai didi

python: TypeError: %c 需要 int 或 char

转载 作者:太空宇宙 更新时间:2023-11-04 10:20:30 26 4
gpt4 key购买 nike

...但是“%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)

关于python: TypeError: %c 需要 int 或 char,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32532315/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com