Skip to content

Instantly share code, notes, and snippets.

@XiongJingzhi
Last active January 18, 2019 09:38
Show Gist options
  • Save XiongJingzhi/0e1619400b8cc8f3c482682c566ec51a to your computer and use it in GitHub Desktop.
Save XiongJingzhi/0e1619400b8cc8f3c482682c566ec51a to your computer and use it in GitHub Desktop.
我们在安装Python3(>=3.3)时,Python的安装包实际上在系统中安装了一个启动器py.exe,默认放置在文件夹C:\Windows\下面
py -2 hello.py
py -3 hello.py
py.exe这个启动器允许你在代码中加入说明
#! python2
#! python3
使用
py hello.py
要使用启动器py.exe来指定pip的版本
py -2 -m pip install XXXX
py -3 -m pip install XXXX
py -2 -m pip -V
py -2 -m pip install pip --upgrade
Python2要在代码文件顶部增加一行说明,才能够在代码中使用中文。
#! python2 需要放在第一行,编码说明可以放在第二行。
#! python2
# coding: utf-8
用virtualenv配置python的虚拟环境,其实就是将某个特定项目(或者说目录下)配置成某个python版本
pip install virtualenv
virtualenv -p c:\Python\Python37-32\python.exe HigEnv
virtualenv -p c:\Python\Python27\python.exe HigEnv
cd HigEnv\Scripts
activate
deactivate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment