当前位置:首页 > Python教程 > python技巧

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)

 

         
    

 

原文:https://www.cnblogs.com/lxmalg/p/11758291.html


【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!

相关教程推荐

其他课程推荐