【发布时间】:2014-03-17 16:20:55
【问题描述】:
我正在制作一个简单的 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。一切都很好,直到重新加载时代码停止。 Heres pythons错误输出
Traceback (most recent call last):
File "./Evacuation.py", line 13, in <module>
str = input("Please input "+ str(curcol) +"," + str(currow))
TypeError: 'int' object is not callable
感谢您的帮助。
【问题讨论】:
-
不要将你的变量命名为
str(或input),你的问题就解决了...... -
currow =+ 1→currow += 1? -
使用
pylint。它会解决这样的常见问题。 -
感谢大家的帮助,你可能已经猜到了,我对 python 比较陌生 :)。