Python中strip和split的使用
来源:互联网 发布:淘宝直播的运营怎么做 编辑:程序博客网 时间:2024/05/17 08:20
strip:参数为空时,默认删除开头和结尾处的空白符,包括’\n’,’\r’,’\t’
split:按字符串(单个字符)全部分割
ipaddrX = "xx173.10.1.101 \t\n"ipaddrX.strip('x') #删除字符串ipaddr中开头和结尾处的x
'173.10.1.101 \t\n'
ipaddrX.strip('x').strip() #strip的参数为空时,默认删除开头和结尾处的空白符,包括'\n','\r','\t'等''
'173.10.1.101'
ipaddr = '173.10.1.101\t'ipaddr.split('.') #按字符串(单个字符)全部分割
['173', '10', '1', '101\t']
ipaddr.strip().split('.') #先删除空白符,再按字符串(单个字符)全部分割
['173', '10', '1', '101']
str = ('www.baidu.com')print(str)str_split = str.split('.',1) #分割1次print(str_split)
www.baidu.com['www', 'baidu.com']
str = ('Python2.0||Python2.7||Python3.4')print(str)str_split=str.split('||') #按字符串(多个字符)分割print(str_split)
Python2.0||Python2.7||Python3.4['Python2.0', 'Python2.7', 'Python3.4']
阅读全文
0 0
- python中strip和split的使用
- Python中strip和split的使用
- python 的 split 和 strip
- python中strip() 函数和 split() 函数的理解
- Python中strip() 函数和 split() 函数的理解
- python中strip() 函数和 split() 函数的理解
- python中strip() 函数和 split() 函数
- python中raw_input().strip().split()
- python 中的split()和strip()
- python中的strip和split
- Python strip() 和split() 函数
- python中 strip()的使用
- python 中strip和split函数,readline,readlines,read的区别
- python strip()函数和Split函数的用法总结
- <python>strip() 函数和 split() 函数的理解
- Python学习笔记:split()函数和strip()函数的使用说明
- <python>strip() 函数和 split() 函数的理解
- python strip()函数和Split函数的用法总结
- 两指针(2)
- 两指针(3)
- ffmpeg 编译
- Qt:关于自定义widget显示不出背景颜色的问题
- 两指针(4)
- Python中strip和split的使用
- Java多线程编程-(13)-从volatile和synchronized的底层实现原理看Java虚拟机对锁优化所做的努力
- Win10下安装Cisco VPN Client终极解决方法
- springmvc工作原理
- css js 实现图片动态切换
- 两指针(5)
- MongoDB:16-MongoDB-索引数组字段和索引子文档字段
- laoshidaima(用户管理商品)
- 排座位 要安排:3个A国人,3个B国人,3个C国人坐成一排。 要求不能使连续的3个人是同一个国籍。 求所有不同方案的总数?