![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
str
devops_sre
道
展开
-
python中bytes与str的互转
前言 实现bytes与str的互相转换 使用 # bytes object b = b"example" # str object s = "example" # str to bytes sb = bytes(s, encoding = "utf8") # bytes to str bs = str(b, encoding = "utf8") # an alternative method # str to bytes sb2 = str.encode(s) # b原创 2020-09-26 17:16:26 · 117 阅读 · 0 评论 -
python中str的替换
前言 在进行代码编辑时,需要对其变量进行替换,生成新的变量 操作 语法 str.replace(old_str, new_str) 示例 old_str = "summer holiday" data = old_str("holiday", "good") 结语 Python replace()方法原创 2020-08-28 14:30:27 · 2896 阅读 · 0 评论 -
python3中str的使用
前言 在程序中,需要对str(字符串)进行处理 使用 1.去掉字符串的空格符、制表符(\t)、换行符(\n、\r\n)等 方法 str.split() 示例 > python Python 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 23:03:10) [MSC v.1916 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information原创 2020-06-06 19:21:29 · 612 阅读 · 0 评论