while conditions:
Loop
while loop
change condition is not dead loop
variables 2 =
while 2> 0:
loop
variable - =. 1
break terminates the current cycle, and break the lower loop body code is not performed
out of this cycle continues for the next cycle (disguised as the last line of the loop body) in a loop when continue to continue in the case of
format
"" "
-------- -------- info
Name:
sex:
address:
telephone:
--------- --------- End
"" "
第一种
a="-------- info --------"
b="姓名:"+name
c="性别:"+age
d="地址:"+addr
e="电话:"+phone
f="--------- end ---------"
name = input("name")
age = input("age")
addr=input("addr")
phone=input("phone")
print(a+\n+b+...)
第二种
name = input("name")
age = input("age")
addr=input("addr")
phone=input("phone")
info="""
-------- info --------
姓名:%s
性别:%s
地址:%s
电话:%s
--------- end ---------
"""%(name,age,addr,phone)
print(info)
When must correspond footprint and filling
When filling the filling in order
% S - string representing location
% D |% i - accounting for digital position
%% - converted into ordinary Percent
name ="值"
j = "progress"
print (f "{name} learning progress is {j}%")
f automatically converted into conventional type of
print (f "{122}, {3300}")
Version in more than python3.6
Operators
Arithmetic operators
+ Plus
-Less
* Multiplication
/except
% Remainder
** a power of
// (divisible (at the floor) divisible downwardly) 2 == 5 // 2
Comparison Operators
Greater than> Less than <, = equal to, greater than or equal to> = Less than or equal <=, not equal! =
Assignment Operators
+ = A + = 1 plus the like either a = a + 1
- = Less like a - = 1 a = a-1 both
Logical Operators
and or not
With or
and operations, are true to be true, there is a fake is a fake
and computing, it is really time to choose the content and behind
and operations, choose the content and the front is false
Priority: ()> not> and> or
Member operator
in the
not in not in
a="alex"
if "b"in a:
print ( "in")
else :
print ( "not")
Coding acquaintance
win - encoding GBK
Linux - utf-8 encoded
MAC - encoding utf-8
ascii code:
do not support the Chinese
one byte
gbk (GB):
English one-byte
Chinese 2 bytes
unicode (Unicode)
English 4 bytes
Chinese four bytes
utf-8
English one byte
Europe 2-byte
Asian 3 bytes
1 byte 8 == == 8bit 1bytes
1K == 1024B
1M == 1024K
. 1G 1024M ==
1T == 1024G