写的一段python老是报错 求解 老是在*cur*的地方报错

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了写的一段python老是报错 求解 老是在*cur*的地方报错相关的知识,希望对你有一定的参考价值。

def addNewFlight(): addFlightNumber = input("Please input a new flight's number:") cur.execute("SELECT FlightNumber From FlightInformation") rows=cur.fetchall() for i in range(0,len(rows)): if addFlightNumber == "%s"%rows[i]: print "The flight number has existed, not need to be added " break else: addStart = input("Please input this flight's starting point:") addTerminal = input("Please input this flight's terminal point:") addDepartureTime = input("Please input this flight's departure time:") addArrivalTime = input("Please input this flight's arrival time:") addFares = int(raw_input("Please input this flight's fares:")) addRemainingTickets = int(raw_input("Please input this flight's remaining tickets:") *cur*.execute("insert into FlightInformation values(%s, %s, %s, %s, %s, %s, %s)" %(addFlightNumber, addStart, addTerminal, addDepartureTime, addArrivalTime, addFares, addRemainingTickets) print "Add new flight successful, now, the new flight's specific information is : " cur.execute("select from FlightInformation where IDNumber=%s",userIDNumber) rows = cur.fetchall() for row in rows: print row[0] break conn.commit()

cur变量你没有赋值就用了啊,数据库如果是mysql的话,应该这样吧:

db = MySQLdb.connect("localhost","root","123456","myciti" )
cur = db.cursor()

参考技术A 建议你发一个python文件的附件。这样那些大牛可以直接 下载运行一下。追问

诶?还可以加附件的??

追答

还真不能,以前提问还没注意,这个很基本的功能居然不能实现。

参考技术B 亲,报错的提示,你也给出来嘛追问

就是跳出一个框:There‘s an error in your program:invalid syntax
然后就跳回去

追答

晕,你语法出错了
*cur*,有这种写法,是说看到这么怪异

追问

没有那两个*
那是我写来做记号的

追答

你这个贴出来的代码,排版全乱了,我现在只能怀疑你 ‘缩进’ 是不是有问题
你截个图嘛

配置Android SDK Manager.exe,老是出现这种错误提示而继续不下去,该怎么弄啊?求解啊,各位大侠

参考技术A GOOGLE 的连接不正常吧,多试几次吧,我国的墙很厉害的

以上是关于写的一段python老是报错 求解 老是在*cur*的地方报错的主要内容,如果未能解决你的问题,请参考以下文章

同时安装Python2与Python3,安装第三方包,老是报错

python 的json为啥老是报错

Python求助在eclipse和pycharm中,通过adb install安装中文名字APK时老是报错,如何解决

我的MYSQL老是出现乱码,在java写的poj里改成中文也会出现乱码!这怎么改?

安装了python3.2.2,安装了win32com,在import的时候老是报错,请达人指教:

用python进行socket编程老是报错error: [Errno 10061] 怎么回事啊??好心人帮帮忙啊!!在线等!谢了