# encode 编码 decode 解码 #编码 msg = '刘小明' result =msg.encode() print(result) #解码 print(result.decode())
startswith判断是否以xxx开头的,或者endswith判断是否以xxx结尾的应用: 文件上传 只能上传图片(jpg,png,bmp,gif)
filename = '笔记.doc'
result = filename.endswith('doc')
print(result)
s = 'hello'
result = s.startswith('h')
print(result)