我正在制作一个简单的python脚本来处理一个表。我使用数组来存储单元格值。 代码如下:
table =[]
hlen = input("Please enter the amount of columns \n")
vlen = input("Please enter the amount of rows \n")
curcol = 1
currow = 1
totcell = hlen*vlen
while (totcell >= curcol * currow):
str = input("Please input "+ str(curcol) +"," + str(currow))
table.append(str)
if (curcol >= hlen):
currow =+ 1
//Process Table
这个程序运行得很好,要求1,1的第一个单元格。一切正常,直到重新加载时代码停止。这里是Python错误输出
^{pr2}$谢谢你的帮助。在
您使用变量名对内置的
str
进行跟踪:第二次,使用
str(currow)
你试图调用str
,现在是int
把它命名为除此之外的任何东西!
另外,您使用的是python2,因此最好使用}
raw_input
,而不是{您正在使用
str
作为从输入返回的int
的变量名。当您使用str(curcol)和str(currow)时,Python指的是它,而不是Python字符串函数。在相关问题 更多 >
编程相关推荐