Little knowledge and advanced coding

'' ' 
Python2 to python3 

' '' 
# python2 
# Print () Print 'ABC' 
# Range () xrange () generator 
# the raw_input () 

# to python3 
# Print ( 'ABC') 
# Range () 
# INPUT () 

# = assignment == equality comparison value is compared to the memory address comparing id (content) 
# in Li1 = [l, 2,3] 
# LI2 in Li1 = 
# LI3 LI2 = 
# Print (id (in Li1), id (LI2)) 

# numeric, character string data of small pool 
# range of numbers -5--256 
# string: 1, can not have special characters 
#         2, s * is 20 is the same address, s * after 21 are two address 
# I1 = 6 
#I2. 6 = 
# Print (ID (I1), ID (I2)) 
# I1 = 300 
# I2 = 300 
# Print (ID (I1), ID (I2)) 


# remaining tuple SET dict List 
# L1 = [. 1 ,] 
# L2 = [. 1,] 
# Print (L1 L2 IS) 

# S = 'Alex' 
# S1 = b'alex ' 
# Print (S, type (S)) 
# Print (S1, type (S1)) 

# s = 'Chinese' 
# Print (S, type (S)) 
# S1 = B 'Chinese' 
# Print (S1, type (S1)) 

S1 = ' Alex ' 
# encode encoding, how str -> bytes, ( )
s11 = s1.encode('utf-8')
s11 = s1.encode('gbk')
print(s11)
s2 = '中国'
s22 = s2.encode('utf-8')
s22 = s2.encode('gbk')
print(s22)

 

Guess you like

Origin www.cnblogs.com/jsit-dj-it/p/11203592.html