控制台打印乱码:
print '你好,世界!'.decode('utf-8')
url = 'http://{0}:{1}/{2}'.format('0.0.0.0', 2375, 'xxx')
url = 'http://{ip}:{port}/{uri}'.format(ip='0.0.0.0', port=2375, uri='xxx')
url = 'http://%s:%d/%s' % ('0.0.0.0', 2375, 'xxx')Windows Python 依赖库 PythonLibs
- 1.找到对应的 
whl包下载 - 2.直接
pip install *.whl或者修改.whl文件为.zip文件,解压缩文件的Python文件夹复制到--python安装目录下的Lib--目录下 
假如
sys.path不对,则使用Python终端sys.path = [...]重新设置即可. 默认环境配置如下:
root@node-40:~# python
Python 2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys 
>>> sys.path
['', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/PILcompat', '/usr/lib/python2.7/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.7']
>>> # /etc/profile
export PYTHONPATH=/usr/lib/python2.7:/usr/lib/python2.7/plat-x86_64-linux-gnu:/usr/lib/python2.7/lib-tk:/usr/lib/python2.7/lib-old:/usr/lib/python2.7/lib-dynload:/usr/local/lib/python2.7/dist-packages:/usr/lib/python2.7/dist-packages:/usr/lib/python2.7/dist-packages/PILcompat:/usr/lib/python2.7/dist-packages/gtk-2.0:/usr/lib/pymodules/python2.7
export PATH=$PATH:$PYTHONPATH- Python2.7 : 
$ py -2 - Python3.x : 
$ py -3 - Python2.7 pip : 
$ py -2 -m pip xxx - Python3.x pip : 
$ pip3 xxx 
settings
- enable Code compatibility inspection: 
settings-->code compatibility inspection 
- 
下载服务器:
- Python2.x
$ python -m SimpleHttpServer默认端口8000$ py -2 -m SimpleHTTPServer默认端口8000$ py -2 -m SimpleHTTPServer 9090指定端口9090- 使用代码:
 
import SimpleHTTPServer SimpleHTTPServer.test()
 - Python3.x
$ python -m http.server$ py -3 -m http.server
 
 - Python2.x
 - 
Json格式化:
$ curl http://localhost:8080/get | python -m json.tool - 
执行Python代码:
$ python -c "print 'hello world!'" - 
解压zip包:
- 创建zip包:
$ python -m zipfile -c tom.zip tom.txt - 解压zip包:
$ python -m zipfile -e tom.zip . - 查看zip包:
$ python -m zipfile -l tom.zip 
 - 创建zip包:
 - 
文件处理:
import shutil shutil.copy('C:\Users\Administrator\Desktop\ctools2.rar','q.rar')
 
- 爬虫
 - RPC
 - 定时任务
 - mysql
 - mongodb
 - redis
 - 数据分析:
maptplotlib,malb,numpy,tesseract - 页面解析技术: 
bs4,xpath - openstack开源模块
 - Python 装饰器
 - Python 多线程/多进程
 - Python 内置模块
 - Python 使用技巧