day003-python acquaintance

The basic process of writing code:
1. Create a file xxx.py
Note: Do not save the file under the Chinese path, file name and do the Chinese name.

2, write code
a note two lines in the file header.
A note two lines in the file header.
B write function codes.

3, the execution code
a open terminal.
B type python command, i.e., the path python code files (Example:. Python d: \ test \ mytest.py)


A knowledge point: xxx.py file header information
# / usr / bin / env Python!
# - * - Coding: UTF-8 - * -


Knowledge point two: input () is used to interact with the user and wait for user input
Note: python 2.7 using raw_input ()
Python 3.5 using the INPUT ()

name = the INPUT ( "Please enter your user name:")
variable name on behalf of that certain " thing"

Knowledge three:
Import getpass # Import module getpass
pwd = getpass.getpass ( 'Enter password:') # invisible information input by the user

Knowledge four points: the variable
num = "123456789" #num variable name; "123456789" is a variable value
Note:
1, variable name:
A numbers, letters, underline combination.
B can not begin with a number.
C variable name can not be python. internal keywords

Knowledge 2.5: basic data types
1, numbers: 1235
2. String: "adges"
. 3, Boolean: True / False


Knowledge 2.6: if the basic conditions statement

1, if conditions: # When the condition is true, on the implementation of the contents of a, otherwise the contents of two
content a
else:
Content of

2, if conditions for a:
content a
elif condition:
Content of
elif three conditions:
the contents of three
else:
the contents of four

knowledge 4.7: while loop
while True:
the contents of a

break
for out of all cycles, and break the following code will not execute
continue
to jump out of this cycle, the next cycle continues

 

 

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/june-L/p/11478914.html