本文介绍了SyntaxError:语法无效。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无论我在哪里放置这个导入的文件,它在

之后的语句主程序都会出现语法错误,无论语法如何。


我想我可能在这个文件中有所改变,但我被困住了。可以

任何人都可以帮忙吗?


#!/ usr / local / bin / python

#Copyright 2004 by Stephen Masterman


#更改数据库连接详细信息。

导入MySQLdb


def connect():

return = MySQLdb.connect(host =" db91x.xxxx.com",

user =" xxxx",

passwd =" ; xxxxx",

db =" homebase_zingers"

);

no matter where I place this imported file,the statement after it in
the main program gets a syntax error, regardless of the syntax.

I think I may have changed something in this file, but I''m stuck. Can
anyone help?

#!/usr/local/bin/python
# Copyright 2004 by Stephen Masterman

#Change the db connection details here.
import MySQLdb


def connect():
return = MySQLdb.connect (host = "db91x.xxxx.com",
user = "xxxx",
passwd = "xxxxx",
db = "homebase_zingers"
);

推荐答案



return是保留关键字。您不能拥有该名称的变量。


-

Roberto Bonvallet

return is a reserved keyword. You cannot have a variable with that name.

--
Roberto Bonvallet





^


你不能指定一个关键字。只需留下这个`` =``out。


Ciao,

Marc''BlackJack''Rintsch

^

You can''t assign to a keyword. Just leave this ``=`` out.

Ciao,
Marc ''BlackJack'' Rintsch


这篇关于SyntaxError:语法无效。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 10:06
查看更多