python命令行模式的用法及流程
1、使用cmd打開命令行窗口。
2、在輸入python時,進入python交互模式。
3、輸入exit(),退出交互模式,在命令行模式下運行.py程序。
實例
C:\Users\86178>python
Python 3.8.3 (default, Jul 2 2020, 17:30:36) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> edit
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'edit' is not defined
>>> exit()
C:\Users\86178>python
Python 3.8.3 (default, Jul 2 2020, 17:30:36) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> hello.py
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'hello' is not defined
>>> exit()
C:\Users\86178>python hello.pu
python: can't open file 'hello.pu': [Errno 2] No such file or directory
C:\Users\86178>python hello.py
python: can't open file 'hello.py': [Errno 2] No such file or directory
C:\Users\86178>cd /d
文件名、目錄名或卷標語法不正確。
C:\Users\86178>cd /d D:
D:\>python hello.py
hello
D:\>python
Python 3.8.3 (default, Jul 2 2020, 17:30:36) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> hello.py
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'hello' is not defined
>>>
知識點擴充:
命令行模式與python交互模式
1.在命令行模式下,可以執(zhí)行 python 進入 Python 交互式環(huán)境,也可以執(zhí)
行 python hello.py 運行一個.py 文件。
2.在 Python 交互式環(huán)境下,只能輸入 Python 代碼并立刻執(zhí)行。
3.Python 交互式環(huán)境會把每一行 Python 代碼的結(jié)果自動打印出來,但是,直接運行 Python 代碼卻不會。
到此這篇關(guān)于python命令行模式的用法及流程的文章就介紹到這了,更多相關(guān)python命令行模式的使用流程內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
python中g(shù)etattr函數(shù)使用方法 getattr實現(xiàn)工廠模式
這篇文章主要介紹了python中g(shù)etattr()這個函數(shù)的一些用法,大家參考使用吧2014-01-01淺析pip安裝第三方庫及pycharm中導(dǎo)入第三方庫的問題
這篇文章主要介紹了淺析pip安裝第三方庫及pycharm中導(dǎo)入第三方庫的問題,本文給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下2020-03-03Python實現(xiàn)線性判別分析(LDA)的MATLAB方式
今天小編大家分享一篇Python實現(xiàn)線性判別分析(LDA)的MATLAB方式,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-12-12使用python編寫簡單的小程序編譯成exe跑在win10上
這篇文章主要介紹了使用python編寫簡單的小程序編譯成exe跑在win10上的相關(guān)資料,需要的朋友可以參考下2018-01-01Python中一些不為人知的基礎(chǔ)技巧總結(jié)
這篇文章主要給大家總結(jié)介紹了Python中一些不為人知的基礎(chǔ)技巧,文中通過示例代碼介紹的非常詳細,對大家學習或者使用python具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2018-05-05Python使用Phantomjs截屏網(wǎng)頁的方法
今天小編就為大家分享一篇Python使用Phantomjs截屏網(wǎng)頁的方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-05-05python數(shù)字圖像處理環(huán)境安裝與配置過程示例
這篇文章主要為大家介紹了python數(shù)字圖像處理環(huán)境安裝與配置過程示例,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2022-06-06