Python First Knowledge

Source: Internet
Author: User

One. The basics of Python

  1. Encoding

#-*-Coding:utf8-*-

Meaning to encode using utf8d

ascill     00000000
     &          00000001
    
   unicode    0000000000000000+
    
    & nbsp;&          0000000000000001
      in          001000000000000111110010
    
      utf-8      How much you can use to represent
     less in utf-8, especially in a Character encoding in Scill
     &          0000 0001
               0010 0000 0000 0001 1111 0010 span>

You need to use the above statement in Python2

Not required in Python3

  Basic input and output statements for 2.python

n = input (' Please enter user name:') # Default input Gets the character type
Print (n) #

   3. Variable name

    Letters
  number
Span style= "COLOR: #000000" >  underline
 
  exception: You cannot start with a number
 python keyword, and you cannot use
  ' and ', ' as ', ' assert ',
  ' Break ', ' class ', ' cont Inue ', ' def ', ' del ', ' Elif ',
  ' Else ', ' except ', ' exec ', ' finally ', ' for ', ' From ',
  ' global ', ' if ', ' Import ', ' on ', ' is ', ' lambda ', ' not ', Br>  ' or ', ' pass ', ' print ', ' raise ', ' return ', ' try ', ' while ',
  ' with ', ' yield

Two. Conditional statements and basic data types

    1.if Else statement

      

N1 = input ('Please enter:')ifN1 = ='Alex': N2= Input ('>>>')ifN2 = ='Confirm': Print ('Alex SB')Else: Print ('Alex DB')Else: Print ('Error')

     Attention:
N1 = "Alex" Assignment
N1 = = ' Alex ' comparison,

      If or else follow the code fast is better 4 spaces

And you have to have the same number of spaces two.

    2.if elif Statement

     If condition 1:
Pass
Elif Condition 2:
Pass
Elif Condition 3:
Pass
Else
Pass

Print (' End ')

      

Python First 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.