#字符串编码转换
b = '你好'
a = b.encode()
print(a)
# 解码
c = a.decode('utf-8')
print(c)
结果
b’\xe4\xbd\xa0\xe5\xa5\xbd’
你好
format用法
a = 'yao is a {} good man'.format(1)
print(a)
b = 'hello {} word {}'.format('python',2)
print(b)
结果
yao is a 1 good man
hello python word 2