Python basic knowledge

Source: Internet
Author: User

When using Python, enter Python directly at the command line to enter Python interaction:

When importing a module, such as the Import OS, dir (OS) is required to see all the properties and methods of the OS.

Here is a program that enables you to press the TAB key to know all the methods of that module:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/4D/84/wKiom1RSZObi7XrKAAHN0vz4hk4419.jpg "title=" tab completion file. jpg "alt=" wkiom1rszobi7xrkaahn0vz4hk4419.jpg "/>

You can do this by saving the above command line to a tab.py and then importing tab to the Python interaction line, and then import the other modules.

Locate tab.py locates the path to the program. More tab.py View the contents of the program.

There is no difference between single and double quotes in Python. Three quotation marks can be used to write higher-degree-of-freedom strings or to annotate.

(Single and double quotes in the shell are different, double quotes are used to reference variables.) )

Like echo "I am $year years old\!" (exclamation points need to be escaped)

There are three ways of importing modules:

    1. Import Math (usage: math.sin ())

    2. Impor Math as MT (usage: Math.sin ())

    3. From Math Import * (usage: sin ())

Python User interaction:

Str=raw_input (). Strip () (Strip effect: Remove the whitespace before and after Str to make the program more robust. )

Int=input ()

For I in range (1,100): (Output 1 to 99)

Finish. (sudo/etc/init.d/httpd restart for restarting Apache server)

This article is from the "Blue Fin Dolphin" blog, please be sure to keep this source http://likunheng.blog.51cto.com/9527645/1569921

Python basic knowledge

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.