In the following code sample, the last line ( print buildConnectionString(myParams)
) is throwing the following error:
Invalid syntax
def buildConnectionString(params):
return ";".join(["%s=%s" % (k, v) for k, v in params.items()])
if __name__ == "__main__":
myParams = {"server":"mpilgrim", \
"database":"master", \
"uid":"sa", \
"pwd":"secret"
}
print buildConnectionString(myParams)
假设您使用的是 Python 3,print 是一个函数,需要用括号括起来:
print(buildConnectionString(myParams))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.