2018年10月22日-Python day1

希望有一个好的未来!!!

执行一个.py文件只能在命令行模式执行,如果敲一个命令python hello.py,看到如下错误:

┌────────────────────────────────────────────────────────┐
│Command Prompt                                    _ □ x │
├────────────────────────────────────────────────────────┤
│Microsoft Windows [Version 10.0.0]                      │
│(c) 2015 Microsoft Corporation. All rights reserved.    │
│                                                        │
│C:> python hello.py                                    │
│python: can't open file 'hello.py': [Errno 2] No such   │
│file or directory                                       │
│                                                        │
│                                                        │
│                                                        │
│                                                        │
│                                                        │
└────────────────────────────────────────────────────────┘

小结

在Python交互式模式下,可以直接输入代码,然后执行,并立刻得到结果。

在命令行模式下,可以直接运行.py文件。

 
原文地址:https://www.cnblogs.com/diandianchao/p/9831963.html