Python2.7 from getting started to mastering

Source: Internet
Author: User

Quick Start

1. Program OUTPUT PRINT statement

(1) Use the PRINT statement to view the value of the object, and output the string representation of the object in the interactive interpreter using the object itself;

(2) Use the Print statement to invoke the STR () display object, and invoke the Repr () display object in the interactive interpreter using the object itself

(3) Use _ In the interpreter has a special meaning, indicating the value of the last expression;

(4) using the string operator% can be used to replace the string function;

(5) Can implement string output redirection;

For example:

" Hello, World " Print Mystringhello,world >>> myString'Hello,World'>>>  _ ' Hello, World '

For example:

Print " %s is%d " % ("python", 1 is 1
Import SYS Print " Fatal error:invalid input! " Fatal error:invalid input!
>>> logfile = open ("/tmp/logfile.txt""a") Print " Fatal error:invalid input! "

2. Program Input raw_input ()

(1) It is not recommended to use the print () and raw_input () functions in a function, but if the function is the input and output is not allowed;

(2) Use Help (raw_input) to view the documentation

For example:

3. Notes

(1) Use the # Comment line

(2) Document string Special note, you can implement the online document function, in the module, class, function of the structure of the first row to use

Python2.7 from getting started to mastering

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.