2-5

2-5

'' ' 
Ternary operator 
result = value 2 value 1 if the condition else 
if the condition is true: result = the value 1 
if the condition is false: result = value 2 



' '' 

A, B, C = 1,. 3,. 5 
D = A IF A> B the else C
 Print (D) 

# if not ternary operator, so it is necessary to write: 
IF A> B: D = A
 the else : D = C
 Print (D) 


'' ' 
ary 
binary 
octal 
decimal 
sixteen hex 

hex represents 
H suffix 
0X prefix 
'' ' 
Print (0x53 )
 Print (0x53 ) 


' '' 
bytes type 
byte data type

python3 most important new features probably be the text and binary data made a clearer distinction. 
Text always unicode, str type is represented by 
binary data represented by the bytes type 


string -> bytes type, encode 
bytes type -> string, decode 

'' ' 
the Test = ' I Love Beijing Tiananmen ' .encode ( ' UTF-8 ' )
 Print (Test) 

Test = B ' \ XE6 \ X88 \ X91 \ XE7 \ X88 \ of xb1 \ xe5 \ x8c \ X97 \ XE4 \ Xba \ XAC \ xe5 \ Xa4 \ xA9 \ xe5 \ XAE \ X89 \ xe9 \ X97 \ xa8 ' .decode ( ' UTF-. 8 ' )
 Print (Test)

 

Guess you like

Origin www.cnblogs.com/python-abc/p/12021742.html
2-5
2-5
2-5