python-str,list,set间的转换实例
2018-06-27 15:06
841 查看
实例如下:
a = '123abbcc!@#' b = ['1', '2', '3', 'a', 'b', 'c', '!', '@', '#'] c = set(['a', '!', 'c', 'b', '@', '#', '1', '3', '2']) str -> list:list(a) result : ['1', '2', '3', 'a', 'b','b', 'c','c','!', '@', '#'] list -> str : ''.join(list) result : 123abc!@# str -> set : set(a) result : set(['a', '!', 'c', 'b', '@', '#', '1', '3', '2']) set类型是无序不重复的 set -> str : ''.join(c) result: a!cb@#132 set -> list : list(c) result : ['a', '!', 'c', 'b', '@', '#', '1', '3', '2'] list -> set : set(b) result : set(['a', '!', 'c', 'b', '@', '#', '1', '3', '2'])
以上这篇python-str,list,set间的转换实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。
您可能感兴趣的文章:
相关文章推荐
- python-str,list,set间的转换
- python 集合 并集、交集 Series list set 转换的实例
- python基础31[list+tuple+set+dict+str+file的成员方法]
- 【学习笔记】Python基础-字典Dict和Set和List与Str扩展
- python 字符串(str)和列表(list)的互相转换
- python3 list、tuple(元组)、str之间的相互转换
- python-list与set相互转换时的一个注意事项
- Python hexstring-list-str之间的转换
- Python的Set和List的性能比较 + 两者之间的转换
- python知识整理--议可变对象和不可变对象以及str、list、tuple、dict、set
- python中从str中提取元素到list以及将list转换为str
- python 中list(列表),tupe(元组),str(字符串),dict(字典)之间的相互转换
- Python的Set和List的性能比较 + 两者之间的转换
- python实现字符串类型 str 转换为 list 类型(unicode 转换为 list)
- Python中list、tuple、str和dict之间的相互转换
- python 集合 并集、交集 Series list set 转换
- python str 转换 list
- python list转换字符串报错TypeError: sequence item 0: expected str instance, int found
- python中从str中提取元素到list以及将list转换为str
- python学习之路-字符串(str)和列表(list)的互相转换