The first step of the 3rd Chapter
1 There are two ways to run your program using Python-using an interactive prompt interpreter or using a source file
Prompt:$ python
Python 2.3.4 (#1, Oct 26 2004, 16:42:40)
[GCC 3.4.2 20041017 (Red Hat 3.4.2-6.fc3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> print ‘hello world‘
hello world
>>>
Source file:
#!/usr/bin/python
# Filename : helloworld.py
print‘Hello World‘
$ python helloworld.py
Hello World
- Note -any content that is to the right of the # symbol is a comment
- Note that you can always run your program on any platform by specifying the interpreter directly on the command line. Just like command python helloworld.py .
2 If you want your program to run from every location? In that case, you can save your program in one of the directories in the PATH environment variable. Each time you run any program, the system looks for the directories listed in the PATH environment variable. Then run the program. Simply copy the source file to one of the directories listed in path to make your program available in any location.
$ echo $PATH
/opt/mono/bin/:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/swaroop/bin
$ cp helloworld.py /home/swaroop/bin/helloworld
$ helloworld
Hello World
3 You need quick information Help for a Python function or statement, you can use the built-in help features, such as runninghelp(str)。
Concise Python tutorial Note one