$ pip install virtualenv
$ pip install virtualenvwrapper-win # windows下的管理工具
$ pip install virtualenvwrapper
$ pip install pipenv
$ workon
新增环境变量
WORKON_HOME
# pip后建立软连接
$ ln -s /usr/local/python3/bin/virtualenv /usr/bin/virtualenv
# Linux配置虚拟环境路径
$ vim ~/.bashrc
# mac配置
$ vim ~/.bash_profile
# 新增
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/python3/bin/virtualenvwrapper.sh
# 执行命令,让配置生效
# Linux
source ~/.bashrc
# mac
source ~/.bash_profile
-p
指定解释器
$ mkvirtualenv -p python3 test_py3
$ workon test_py3
$ deactivate
$ rmvirtualenv test_py3
$ pip frezz >requirements.txt
$ pip install -r requirements.txt
virtualenv卸载一个包之后,相关依赖不会被同步卸载
与项目绑定
$ pipenv install
$ pipenv shell
exit
在哪个路径下操作,就安装到哪个环境
$ pipenv install requests
$ pipenv graph
当前环境的依赖不会被卸载
移植Pipfile
和Pipfile.lock
后重新生成不会携带
$ pipenv uninstall requests
$ pipenv install --dev requests
$ pipenv lock -r >requirements.txt
Pipfile
和Pipfile.lock
不会被删除
$ pipenv --rm
python之禅 import this The Zen of Python, by Tim Peters Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts. Special cases aren't special enough to break the rules. Although practicality beats purity. Errors should never pass silently. Unless explicitly silenced. In the face of ambiguity, refuse the temptation to guess. There should be one-- and preferably only one --obvious way to do it. Although that way may not be obvious at first unless you're Dutch. Now is better than never. Although never is often better than right now. If the implementation is hard to explain, it's a bad idea. If the implementation is easy to explain, it may be a good idea. Namespaces are one honking great idea -- let's do more of those!
# 左对齐
foo = long_function_name(var_one, var_two,
var_three, var_four)
# 换行缩进
foo = long_function_name(
var_one, var_two,
var_three, var_four)
# 用更多的缩进来与其他行区分
foo = long_function_name(
var_one, var_two, var_three,
var_four)
与代码在同一行
第一行:对函数/类整体功能说明 参数说明 :param var_one: 参数1 是干嘛的 :type var_one:int 返回值说明 :return:
PEP257:https://github.com/qiuxiang/pep/blob/master/peps/257.md
__all__=[]
使用*
导入时候只会导入all的[]中的的内容
https://pythonguidecn.readthedocs.io/zh/latest/writing/structure.html