- The Python Apprentice
- Robert Smallshire Austin Bingham
- 186字
- 2021-07-02 22:16:59
Running Python programs from the operating system shell
Switch to a console with your operating system's shell prompt and change to the new pyfund directory:
$ cd pyfund
We can execute our module simply by calling Python and passing the module's filename:
$ python3 words.py
The command would be as follows if on Mac or Linux:
> python words.py
When on Windows.
When you press Enter, after a short delay you'll be returned to the system prompt. Not very impressive, but if you got no response then the program is running as expected. If, on the other hand, you saw some error out, then something it wrong. An HTTPError, for example, indicates there's a network problem, whilst other types of errors probably mean you have mistyped the code.
Let's add another for-loop to the end of the program to print out one word per line. Add this code to the end of your Python file:
for word in story_words:
print(word)
If you go to your command prompt and execute the code again, you should see some output. Now we have the beginnings of a useful program!
- Mastering Spring MVC 4
- 數據結構習題精解(C語言實現+微課視頻)
- 深入淺出Windows API程序設計:編程基礎篇
- Python機器學習經典實例
- 快速念咒:MySQL入門指南與進階實戰
- 一塊面包板玩轉Arduino編程
- Building Serverless Architectures
- 大學計算機基礎
- uni-app跨平臺開發與應用從入門到實踐
- WCF技術剖析(卷1)
- JavaScript Concurrency
- Android嵌入式系統程序開發(基于Cortex-A8)
- Getting Started with hapi.js
- Java EE應用開發及實訓
- 軟件自動化測試實戰解析:基于Python3編程語言