python学习小记之一

第一次运行了这么一段程序:

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 "<pyshell#4>", line 4

    """Build a connection string from a dictionary of parameters.


Returns string."""

                                                                


                  ^

IndentationError: expected an indented block

这到底是怎么一回事呀,呜呜呜。

-----/解答:需要缩进,有冒号的下一行往往要缩进/,再次运行

还是报错/SyntaxError: invalid syntax,另外在return被标记成了红色/


你可能感兴趣的:(python)