python 中not all arguments converted during string formatting

PromiseCN 2017-08-29 06:15:04
year=input("请输入年:\n")
month=input("请输入月:\n")
day=input("请输入日:\n")

m=[31,28,31,30,31,30,31,31,30,31,30,31]

if(year%400==0 or (year%100!=0 and year%4==0)):
m[1]=29;

x=0

for i in range[0,month-1]:
x+=m[x]

x=x+day

print("it is the %d day" %x)
大佬看看为什么会出现not all arguments converted during string formatting
初学者不太懂
...全文
5135 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
sanGuo_uu 2017-08-30
  • 打赏
  • 举报
回复 1
你的year用input赋值过来是string, 但是你后面又把它当作数值用。 报错的原因应该是这个。 把那3个赋值过来的值都转成数值吧
PromiseCN 2017-08-29
  • 打赏
  • 举报
回复
我发现问题了,改了一下。错误有点多,哈哈

37,744

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • WuKongSecurity@BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧