3.8. Summary
小结
The odbchelper.py program
and its output should now make perfect sense.
程序odbchelper以及它的输出你应该都明白了
- 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)
Here is the output of odbchelper.py:
这是程序的输出:
- server=mpilgrim;uid=sa;database=master;pwd=secret
Before diving into the next chapter, make sure you're
comfortable doing all of these things:
再继续深入下一章之前,首先确定你自己可以轻松的完成下面的事情:
- Using the Python IDE to test expressions
interactively
- 可以交互的在Python IDE中测试表达式
- Writing Python programs and running them
from within your IDE, or from the command line
- 写一个Python程序,要么在你的IDE运行,要么在命令行运行
- Importing modules and calling their
functions
- 能导入模块并可以调用函数
- Declaring
functions and using doc strings, local
variables, and proper
indentation
- 声明函数,并使用文档化字符串(函数注释),局部变量以及适当的缩进。
- Defining dictionaries, tuples,
and lists
- 定义字典,tuple以及列表
- Accessing attributes and methods of any
object, including strings, lists, dictionaries, functions, and
modules
- 能够访问任意对象的属性和方法,如字符处啊,列表,字典,函数,模块
- Concatenating values through string
formatting
- 通过格式化字符串来连接字符串
- Mapping lists into
other lists using list comprehensions
- 通过列表复合操作能将一个列表映射成其它列表
- Splitting strings into lists and
joining lists into strings
- 字符串可以分割成列表,同时join将列表连接成字符串
阅读(856) | 评论(0) | 转发(0) |