Concise Python tutorial Note one

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.