2016年10月22日

摘要: 10.1. Operating System Interface The os module provides dozens of functions for interacting with the operating system: >>> >>> import os >>> os.getcwd 阅读全文

posted @ 2016-10-22 15:44 通天树 阅读(183) 评论(0) 推荐(0) 编辑

摘要: Before introducing classes, I first have to tell you something about Python’s scope rules. Class definitions play some neat tricks with namespaces, an 阅读全文

posted @ 2016-10-22 08:59 通天树 阅读(263) 评论(0) 推荐(0) 编辑

2016年10月21日

摘要: Strings can easily be written to and read from a file. Numbers take a bit more effort, since the read() method only returns strings, which will have t 阅读全文

posted @ 2016-10-21 16:49 通天树 阅读(182) 评论(0) 推荐(0) 编辑

摘要: Packages are a way of structuring Python’s module namespace by using “dotted module names”. For example, the module name A.B designates a submodule na 阅读全文

posted @ 2016-10-21 13:27 通天树 阅读(479) 评论(0) 推荐(0) 编辑

摘要: To speed up loading modules, Python caches the compiled version of each module in the __pycache__ directory under the name module.version.pyc, where t 阅读全文

posted @ 2016-10-21 13:03 通天树 阅读(1216) 评论(0) 推荐(0) 编辑

摘要: When you run a Python module with python fibo.py <arguments> python fibo.py <arguments> the code in the module will be executed, just as if you import 阅读全文

posted @ 2016-10-21 12:49 通天树 阅读(278) 评论(0) 推荐(0) 编辑

摘要: The conditions used in while and if statements can contain any operators, not just comparisons. The comparison operators in and not in check whether a 阅读全文

posted @ 2016-10-21 12:09 通天树 阅读(235) 评论(0) 推荐(0) 编辑

摘要: When looping through dictionaries, the key and corresponding value can be retrieved at the same time using the items() method. >>> >>> knights = {'gal 阅读全文

posted @ 2016-10-21 11:53 通天树 阅读(181) 评论(0) 推荐(0) 编辑