-2
我試圖按照教程這裏找到:http://www.diveintopython.net/getting_to_know_python/index.htmldiveintopython.net示例獲取語法錯誤:無效的語法
下面是我在做什麼...
$ cat odbchelper.py
def buildConnectionString(params):
"""Build a connection string from a dictionary of parameters.
Returns string."""
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)
...當我運行上面的腳本我得到這個輸出...
$ python3 odbchelper.py
File "odbchelper.py", line 13
print buildConnectionString(myParams)
^
SyntaxError: invalid syntax
...我不知道這裏有什麼問題。它是python3的東西嗎?如果你想使用它的Python 3
感謝
http://www.diveintopython3.net/ –