摘要: 可变类型与不可变类型 不可变类型 s1 = '^^^^^success^^^^' print(s1.strip('^')) # success 本身并没有修改 是产生了新的结果 print(s1) # ^^^^^success^^^^ # 查看内存地址 print(id(s1)) # 2168071 阅读全文
posted @ 2022-03-09 21:54 一梦便是数千载 阅读(44) 评论(0) 推荐(0)
摘要: 字符串的其他内置方法 常见操作 1.移除字符串首尾的指定字符,可以自定义方向 str1 = '^^^^^trump^^^^^' print(str1.strip('^')) # trump print(str1.lstrip('^')) # trump^^^^^,移除字符串左边的指定字符 print 阅读全文
posted @ 2022-03-09 21:00 一梦便是数千载 阅读(38) 评论(0) 推荐(0)