欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

关于内容的格式化清理

程序员文章站 2022-07-14 23:40:55
...

移除字符串头尾指定的字符序列

#!/usr/bin/python
# -*- coding: UTF-8 -*-

str = "00000003210Runoob01230000000"; 
print str.strip( '0' );  # 去除首尾字符 0

str2 = "   Runoob      ";   # 去除首尾空格
print str2.strip();

str = "123abcrunoob321"
print (str.strip( '12' ))  # 字符序列为 12

.strip('\n')  #去掉回车
.strip() #去掉空格

用/来分割内容(内容中有/)

.split('/')
相关标签: 爬虫 格式化

上一篇: JQ

下一篇: JQ