C ++ ape's Python note 01

Source: Internet
Author: User

Annotation prefix # 

# ! /Usr/bin/Python
# Filename: helloworld. py
Print   ' Hello python. '


String

1. 'is the same"

2. ''' is used to define multi-line strings and can be used freely. 'And"

>>>   Print   ''' This is a multi-line string. This is 1st line.
This is Second line.
"What's ur name? ", I asked.
"My name is fourth line! ". '''
This Is A Multi - Line string. This Is 1st line.
This Is Second line.
" What's ur name? " , I asked.
" My name is fourth line! " .

>>>

3. Escape Character \

4. Natural string prefix, R or R

Natural string: a string that does not recognize escape characters.

5. Unicode string prefix, U or U

6. The string that is put together will automatically Cascade

7. Separate output content, similar to cascade, but a space is automatically added

>>>   Print   ' This is '   " A sentence. "
This isa sentence.
>>>   Print   ' This is ' , " A sentence. "

ThisIsA sentence. 

 

Separate statements

Or the end of a physical row to indicate the end of a statement.

However, the semicolon is usually not seen in Py;

I =   5
Print I

I= 5;PrintI

I= 5;PrintI;

I= 5;
PrintI;

 

ProgramBlock Division

Use indentation to represent the program hierarchy

RecommendedSingle TabOrTwo or four spaces 

Operator

1. **, power, X ** y, returns the Y Power of X.

2. //, division. Returns the integer part of the operator.

3 .~, Flip by bit ,~ X returns-(x + 1 ),~ 5.

4. Not, And, Or, logical operators.

 

 

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.