1、使用cmd打开命令行窗口。
2、在输入python时,进入python交互模式。
3、输入exit(),退出交互模式,在命令行模式下运行.py程序。
实例
C:\Users\86178>python Python3.8.3(default,Jul22020,17:30:36)[MSCv.191664bit(AMD64)]::Anaconda,Inc.onwin32 Type"help","copyright","credits"or"license"formoreinformation. >>>edit Traceback(mostrecentcalllast): File"<stdin>",line1,in<module> NameError:name'edit'isnotdefined >>>exit() C:\Users\86178>python Python3.8.3(default,Jul22020,17:30:36)[MSCv.191664bit(AMD64)]::Anaconda,Inc.onwin32 Type"help","copyright","credits"or"license"formoreinformation. >>>hello.py Traceback(mostrecentcalllast): File"<stdin>",line1,in<module> NameError:name'hello'isnotdefined >>>exit() C:\Users\86178>pythonhello.pu python:can'topenfile'hello.pu':[Errno2]Nosuchfileordirectory C:\Users\86178>pythonhello.py python:can'topenfile'hello.py':[Errno2]Nosuchfileordirectory C:\Users\86178>cd/d 文件名、目录名或卷标语法不正确。 C:\Users\86178>cd/dD: D:\>pythonhello.py hello D:\>python Python3.8.3(default,Jul22020,17:30:36)[MSCv.191664bit(AMD64)]::Anaconda,Inc.onwin32 Type"help","copyright","credits"or"license"formoreinformation. >>>hello.py Traceback(mostrecentcalllast): File"<stdin>",line1,in<module> NameError:name'hello'isnotdefined >>>
以上就是python命令行模式的使用流程,希望对大家有所帮助。更多Python学习指路:Python基础教程
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
评论(0)