Python では、次のコードの型に問題があります。
>>> curRow = 1
>>> curCol = 2
>>> type(curRow)
type 'int'
>>> cur.execute("select COUNT(*) from adjacency where r = %d and c = %d", (curRow, curCol))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build/bdist.macosx-10.8-intel/egg/MySQLdb/cursors.py", line 183, in execute
TypeError: %d format: a number is required, not str
r
およびc
は両方ともint
表のフィールドであることに注意してくださいadjacency
私は非常に混乱してcurRow
おりcurCol
、明らかにタイプint
であり、%d
私に を与えることを意味しますint
。文字列として混乱しているpythonは何ですか?