第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

Windows下Python2與Python3間的隨意切換

標(biāo)簽:
Python

Windows中Python2与Python3并存,随意切换版本 :

首先需要知道,python默认执行版本由系统环境变量中Python2和Python3的先后顺序决定;

这儿给大家展示在不同情况下利用不同的方法调用python;

#1:Python Launcher调用参数

> py --helpPython Launcher for Windows Version 3.7.150.1013usage:py [launcher-args][python-args] script [script-args]Launcher arguments:-2     : Launch the latest Python 2.x version-3     : Launch the latest Python 3.x version-X.Y   : Launch the specified Python version
     The above all default to 64 bit if a matching 64 bit python is present.-X.Y-32: Launch the specified 32bit Python version-X-32  : Launch the latest 32bit Python X version-X.Y-64: Launch the specified 64bit Python version-X-64  : Launch the latest 64bit Python X version-0  --list       : List the available pythons-0p --list-paths : List with paths

py -2 #调用Python2
py -3 #调用Python3


webp

img

程序运行:
py -2 *.py #运行python2程序


py -3 *.py#运行python3程序
下面是一个python2程序的例子,当使用py -3时,运行失败;

webp

img


#2:修改执行程序.exe名字

..\Python37\python.exe可以修改为python2.exe

..\Python27\python.exe可以修改为python3.exe

这样直接调用python2与python3就不会混乱了;

#3:程序中申明

在python程序首行添加#! python3指定由python3解释运行;

在python程序首行添加#! python2指定由python2解释运行;

#3:pip运行

py -2 -m pip install numpy  #pip2 install numpy
py -3 -m pip install numpy #pip3 install numpy

#4:Python Launcher for Windows

python launcher是python3.3新增的一个功能,它对所有有的python版本都是兼容的;Python launcher for Windows可以帮助程序或命令选择最合适的python版本作为解释器,而不是最近安装的python版本;安装3.3及更新版本的python时,python launcher默认加入到path中。

详细信息见Python Launcher for Windows

py是python launcher下的一个命令;

##打开最近安装的python版本

> py Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] on win32Type "help", "copyright", "credits" or "license" for more information.

##查看py详细参数

>py -h

Python Launcher for Windows Version 3.7.150.1013usage:py [launcher-args][python-args] script [script-args]

Launcher arguments:-2     : Launch the latest Python 2.x version
-3     : Launch the latest Python 3.x version
-X.Y   : Launch the specified Python version
     The above all default to 64 bit if a matching 64 bit python is present.
-X.Y-32: Launch the specified 32bit Python version
-X-32  : Launch the latest 32bit Python X version
-X.Y-64: Launch the specified 64bit Python version
-X-64  : Launch the latest 64bit Python X version
-0  --list       : List the available pythons
-0p --list-paths : List with paths

The following help text is from Python:usage: C:\Program Files\Python37\python.exe [option] ... [-c cmd | -m mod | file | -][arg] ...
Options and arguments (and corresponding environment variables):
-b     : issue warnings about str(bytes_instance), str(bytearray_instance)         and comparing bytes/bytearray with str. (-bb: issue errors)
-B     : don't write .pyc files on import; also PYTHONDONTWRITEBYTECODE=x
-c cmd : program passed in as string (terminates option list)
-d     : debug output from parser; also PYTHONDEBUG=x
-E     : ignore PYTHON* environment variables (such as PYTHONPATH)
-h     : print this help message and exit (also --help)
-i     : inspect interactively after running script; forces a prompt even         if stdin does not appear to be a terminal; also PYTHONINSPECT=x
-I     : isolate Python from the user's environment (implies -E and -s)
-m mod : run library module as a script (terminates option list)
-O     : remove assert and __debug__-dependent statements; add .opt-1 before
         .pyc extension; also PYTHONOPTIMIZE=x
-OO    : do -O changes and also discard docstrings; add .opt-2 before
         .pyc extension
-q     : don't print version and copyright messages on interactive startup
-s     : don't add user site directory to sys.path; also PYTHONNOUSERSITE
-S     : don't imply 'import site' on initialization
-u     : force the stdout and stderr streams to be unbuffered;
         this option has no effect on stdin; also PYTHONUNBUFFERED=x
-v     : verbose (trace import statements); also PYTHONVERBOSE=x
         can be supplied multiple times to increase verbosity
-V     : print the Python version number and exit (also --version)         when given twice, print more information about the build
-W arg : warning control; arg is action:message:category:module:lineno
         also PYTHONWARNINGS=arg
-x     : skip first line of source, allowing use of non-Unix forms of #!cmd
-X opt : set implementation-specific option
--check-hash-based-pycs always|default|never:
    control how Python invalidates hash-based .pyc files
file   : program read from script file

         : program read from stdin (default; interactive mode if a tty)
arg ...: arguments passed to program in sys.argv[1:]



作者:_eason_
链接:https://www.jianshu.com/p/0ca483fd6e0c


點(diǎn)擊查看更多內(nèi)容
TA 點(diǎn)贊

若覺(jué)得本文不錯(cuò),就分享一下吧!

評(píng)論

作者其他優(yōu)質(zhì)文章

正在加載中
  • 推薦
  • 評(píng)論
  • 收藏
  • 共同學(xué)習(xí),寫下你的評(píng)論
感謝您的支持,我會(huì)繼續(xù)努力的~
掃碼打賞,你說(shuō)多少就多少
贊賞金額會(huì)直接到老師賬戶
支付方式
打開微信掃一掃,即可進(jìn)行掃碼打賞哦
今天注冊(cè)有機(jī)會(huì)得

100積分直接送

付費(fèi)專欄免費(fèi)學(xué)

大額優(yōu)惠券免費(fèi)領(lǐng)

立即參與 放棄機(jī)會(huì)
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)

舉報(bào)

0/150
提交
取消