Python字符串学习笔记

# 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)

 

 

 

posted @ 2019-10-29 13:48  你明哥哥  阅读(107)  评论(0)    收藏  举报