我剛剛開始使用python。我正在執行Ubuntu中Mark Pilgrim的「潛入Python」中給出的簡單程序。該程序如下:IndentationError:預計有一個縮進塊
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)
但它顯示如下錯誤:
File "./1.py", line 3
Returns string."""
^
IndentationError: expected an indented block
我試圖像在第3行的回報面前給人一種空間,那麼替代的空間使用幾件事情一個標籤。 任何人都可以幫助我找出錯誤是什麼,爲什麼它來了,等等,還有一些簡單的教程可以讓我們繼續。
在此先感謝..
你試過去削弱'如果__name__ == 「__main __」:'? – Volatility 2013-02-11 08:36:32