【发布时间】:2009-09-11 20:20:39
【问题描述】:
def dispcar ( self, reg ):
print ("The car information for '%s' is: "), (reg)
numrows = int(self.dbc.rowcount) #get the count of total rows
self.dbc.execute("select * from car where reg='%s'") %(reg)
for x in range(0, numrows):
car_info = self.dbc.fetchone()
print row[0], "-->", row[1]
上面的代码给出了这个错误:
self.dbc.execute("select * from car where reg='%s' " %(reg)
TypeError: unsupported operand type(s) for %: 'long' and 'str'
谁能帮我理解为什么会出现这个错误?
仅供参考:reg 是用户在函数 getitem 中输入的 raw_input var i,并将 reg var 作为参数传递给此函数。
【问题讨论】: