python basis (twelve) - Small knowledge gathering and advanced coding

'''
python2 python3
'''
#python2
#print()  print 'abc'
#range()   xrange() 生成器
# raw_input()
#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 =
# = LI2 LI3
# 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 * 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))

List dict tuple remaining SET #
# 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, () (because the transmission and storage must be bytes)
S11 = s1.encode ( 'UTF-. 8')
S11 = s1.encode ( 'GBK')
Print (S11)
S2 = 'Chinese'
S22 = s2.encode ( 'UTF-. 8')
S22 = s2.encode ( 'GBK')
Print (S22)

Guess you like

Origin www.cnblogs.com/qingmuzi/p/12630268.html