Secret Recipes of the Python Ninja
上QQ阅读APP看书,第一时间看更新

How to do it...

  1. A number of options are available for the Python command-line call. To enter interactive mode, call Python with no additional options:
      $ python
Python 3.6.3 |Anaconda, Inc.| (default, Oct 13 2017, 12:02:49)
[GCC 7.2.0] on linux

Type "help", "copyright", "credits" or "license" for
more information.

>>>
  1. To execute a regular Python program with no special options, add the program name:
      $ python <script>.py
  1. To execute a series of Python commands without entering interactive mode or calling a file, use -c:
      $ python -c "print('Hello World')"
  1. To call a Python module as a standalone program, use -m:
      $ python -m random
  1. Discussion of the other possible options is provided in the following section.