Python 包的相对导入讲解
摘要:【Python 包的相对导入讲解】 参考:http://www.dai3.com/python-import.html
阅读全文
Looping Techniques
摘要:【Looping Techniques】 1、When looping through dictionaries, the key and corresponding value can be retrieved at the same time using the items() method.
阅读全文
urllib.request
摘要:【urllib.request】 1、urlopen结果保存在内存。 2、ulrretrieve结果保存到文件。 3、response有read方法。 4、可以创建Request对象。 5、发送Post数据,需要encode()成ascii的byte. 6、url中加入query 7、加入User-
阅读全文
URL Parsing
摘要:【URL Parsing】 urllib.parse.urlparse(urlstring, scheme='', allow_fragments=True) Parse a URL into six components, returning a 6-tuple. This corresponds
阅读全文
URL Quoting
摘要:【URL Quoting】 The URL quoting functions focus on taking program data and making it safe for use as URL components by quoting special characters and ap
阅读全文
安装BeautifulSoup
摘要:【安装BeautifulSoup】 $ pip install beautifulsoup4 参考:https://www.crummy.com/software/BeautifulSoup/bs4/doc/
阅读全文
Keynote of Python III
摘要:【Keynote of Python III】 1、许多大型网站是用Python开发的,例如YouTube、Instagram,还有国内的豆瓣。很多大公司,包括Google、Yahoo等,甚至NASA(美国航空航天局)都大量地使用Python。 2、print()会依次打印每个字符串,遇到逗号“,”
阅读全文
python的路径
摘要:【python的路径】 1、PYTHONHOME Change the location of the standard Python libraries. By default, the libraries are searched in prefix/lib/pythonversion and
阅读全文
WSGI
摘要:【WSGI】 WSGI:Web Server Gateway Interface。 WSGI接口定义非常简单,它只要求Web开发者实现一个函数,就可以响应HTTP请求。我们来看一个最简单的Web版本的“Hello, web!”: 上面的application()函数就是符合WSGI标准的一个HTTP
阅读全文
PIL
摘要:【PIL】 PIL:Python Imaging Library,已经是Python平台事实上的图像处理标准库了。PIL功能非常强大,但API却非常简单易用。 由于PIL仅支持到Python 2.7,加上年久失修,于是一群志愿者在PIL的基础上创建了兼容的版本,名字叫Pillow,支持最新Pytho
阅读全文
threadlocal
摘要:【threadlocal】 Thread-local data is data whose values are thread specific. To manage thread-local data, just create an instance of local (or a subclass
阅读全文
queue
摘要:【queue】 参考:https://docs.python.org/3.5/library/queue.html
阅读全文
pickle
摘要:【pickle】 Python提供了pickle模块来实现序列化。 首先,我们尝试把一个对象序列化并写入文件: pickle.dumps()方法把任意对象序列化成一个bytes,然后,就可以把这个bytes写入文件。或者用另一个方法pickle.dump()直接把对象序列化后写入一个file-lik
阅读全文
__iter__
摘要:【__iter__】 如果一个类想被用于for ... in循环,类似list或tuple那样,就必须实现一个__iter__()方法,该方法返回一个迭代对象,然后,Python的for循环就会不断调用该迭代对象的next()方法拿到循环的下一个值,直到遇到StopIteration错误时退出循环。
阅读全文
__future__
摘要:【__future__】 __future__用于改变python特性。 参考:http://www.liaoxuefeng.com/wiki/001374738125095c955c1e6d8bb493182103fac9270762a000/001386820023084e5263fe54fde
阅读全文
map/reduce of python
摘要:【map/reduce of python】 参考: http://www.liaoxuefeng.com/wiki/001374738125095c955c1e6d8bb493182103fac9270762a000/00141861202544241651579c69d4399a9aa135af
阅读全文
使用__slots__
摘要:【使用__slots__】 参考: 1、http://www.liaoxuefeng.com/wiki/001374738125095c955c1e6d8bb493182103fac9270762a000/0013868200605560b1bd3c660bf494282ede59fee17e781
阅读全文
construction of tuples containing 0 or 1 items
摘要:【construction of tuples containing 0 or 1 items】 the syntax has some extra quirks to accommodate these. Empty tuples are constructed by an empty pair
阅读全文