Python 实现字符串转换成列表 实现str转换list
2018-06-27 13:39
579 查看
本博客转载而来:转载自:https://www.cnblogs.com/xuchunlin/p/6676288.html
本博客转载而来:转载自:http://www.cnblogs.com/kiddy/p/5143031.html
其中Python strip() 方法用于移除字符串头尾指定的字符
split()就是将一个字符串分裂成多个字符串组成的列表
>>> image ='1.jsp,2.jsp,3.jsp,4.jsp' >>> image_list = image.strip(',').split(',') >>> print image_list ['1.jsp', '2.jsp', '3.jsp', '4.jsp'] >>>
python string与list互转
因为python的read和write方法的操作对象都是string。而操作二进制的时候会把string转换成list进行解析,解析后重新写入文件的时候,还得转换成string。
import string str = 'abcde' list = list(str) list ['a', 'b', 'c', 'd', 'e'] str 'abcde' str_convert = ''.join(list) str_convert 'abcde'
阅读更多
相关文章推荐
- python实现字符串类型 str 转换为 list 类型(unicode 转换为 list)
- python 字符串(str)和列表(list)的互相转换
- python 中list(列表),tupe(元组),str(字符串),dict(字典)之间的相互转换
- python 字符串(str)和列表(list)的互相转换
- python学习之路-字符串(str)和列表(list)的互相转换
- Python中列表list以及list与数组array的相互转换实现方法
- python基础数据结构——列表(list), 元祖(tuple), 字典(dict), 字符串(string), 集合(set) 介绍及相互转换
- python中str(字符串)、list(列表)、tuple(元组)、dict(字典)相互转化关系及字典键-值遍历
- Python 实现字符串转换成列表 实现str转换list
- python中的列表(list),字典(dict),字符串(str)的基本操作
- 人生苦短之我用Python篇(列表list、字典dict、元组tuple、字符串str)
- python list转换字符串报错TypeError: sequence item 0: expected str instance, int found
- python基础学习——列表(list), 元祖(tuple), 字典(dict), 字符串(string), 集合(set) 介绍及相互转换
- Python中实现字符串类型与字典类型相互转换的方法
- Python 列表(list)、字典(dict)、字符串(string)常用基本操作小结
- Python中实现字符串类型与字典类型相互转换的方法
- istringstream字符串流,实现类似字符串截取的功能,字符串流中的put,str()将流转换成为字符串string
- Python 列表(list)、字典(dict)、字符串(string)常用基本操作小结
- 【Python】实现字符串分割功能 类似于str.split()
- python之字符串,列表转换截取记录