Python2 與Python3 共存問題

2022-10-11 08:27:08 字數 1041 閱讀 1716

python 2 與 python 3 共存

安裝 python 3.3 以上的版本時,python會在c:\windows資料夾下安裝啟動器py.exe。

雙擊指令碼呼叫的就是這個程式:

1,如果系統中同時存在 python 2 和 python 3,可用它指定版本來執行**:2,3就是版本號

py -2 helloworld.py

py -3 helloworld.py

2,直接在python指令碼第一行指定版本:可以雙擊,也可以命令列執行:

#! python3
py helloworld.py
如果沒有在首行指定版本而用上述命令執行或雙擊,則預設呼叫python 2

3,使用pip:-m pip表示執行 pip 模組

py -2 -m pip install requests

py -3 -m pip install requests

原有的python和pip命令仍然有效,預設執行哪乙個版本呢?看環境變數中路徑的先後次序。

c:\python34\;c:\python34\scripts;c:\python27\;c:\python27\scripts;

Python 2 與Python 3的區別

1.除號 與整除號 python 2中,是整除 python 3中,是常規除法,是整除 2.raw input與input python 2用raw input python 3用input 都表示輸入函式。3.print與print 以及逗號 python 2中,print my print na...

Python3 與 Python2 的不同

至於學習 python3 和 python2,我了解到的觀點是這樣的。1 現在很多的專案都還是在用 python2,學習 python2 還是有意義的 2 python2 在 python 的官方已經公布了在什麼什麼時間停止維護,所以對於新手來說,學習 python2 的價值不是很大,所以直接 py...

Python2 與Python3 的區別

1.print函式 py2中print是乙個語法結構,如 print value py3中print是乙個函式,如 print value 2.除法運算 py2中兩個整數除法得到的是0,要想得到浮點數結果,則被除數或除數二者要有乙個是浮點數才行。如 print 1 4 0 print 1 4.0.2...