29 October 2016

How to write and check result in your first Python Program

First Python Program
# FirstPythonProgram:
The first Python progrm looks like the below

My first program: 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)

Running Programs in UNIX

On UNIX-compatible systems (including Mac OS X), you can run a Python program from the command line: python odbchelper.py

The output of odbchelper.py will look like this:
server=mpilgrim;uid=sa;database=master;pwd=secret

No comments:

Post a Comment

Thanks for your message. We will get back you.

© 2010-2017 Biganalytics.me. All rights reserved.. Powered by Blogger.

Total Pageviews

All material, files, logos and trademarks within this site are properties of their respective organizations.