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.在命令行模式下,可以执行 python 进入 Python 交互式环境,也可以执
行 python hello.py 运行一个.py 文件。
2.在 Python 交互式环境下,只能输入 Python 代码并立刻执行。
3.Python 交互式环境会把每一行 Python 代码的结果自动打印出来,但是,直接运行 Python 代码却不会。
到此这篇关于python命令行模式的用法及流程的文章就介绍到这了,更多相关python命令行模式的使用流程内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!
相关文章
PyCharm MySQL可视化Database配置过程图解
这篇文章主要介绍了PyCharm MySQL可视化Database配置过程图解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下2020-06-06
Python可视化Matplotlib散点图scatter()用法详解
这篇文章主要介绍了Python可视化中Matplotlib散点图scatter()的用法详解,文中附含详细示例代码,有需要得朋友可以借鉴参考下,希望能够有所帮助2021-09-09
高性能web服务器框架Tornado简单实现restful接口及开发实例
Tornado和现在的主流Web服务器框架(包括大多数Python的框架)有着明显的区别:它是非阻塞式服务器,而且速度相当快。得利于其 非阻塞的方式和对epoll的运用,Tornado每秒可以处理数以千计的连接,这意味着对于实时Web服务来说,Tornado是一个理想的Web框架。2014-07-07


最新评论