-4

私はPythonが初めてで、いくつかのプログラムを試していました。これにはまりました。

Python 3.2.5 (default, May 15 2013, 23:06:03) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> 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)

SyntaxError: invalid syntax
>>> 
4

1 に答える 1

1

Printはpython 3の関数なので変更

print buildConnectionString(myParams)

に:

print(buildConnectionString(myParams))
于 2013-10-06T09:40:56.157 に答える