列表字符串字典互转,enumerate
2018-09-11 17:07
190 查看
列表转换成字符串
max=[1,2,3,4,5,6,7,8,9,10]max_str=str(max)
max_list=list(str(max))
print(str(max))
print (max_list)
print (type(max_str))
print (type(max_list))
#字典转换成列表,数据成为元祖
infoo={'on1':"张家辉",
'on2':"xuwuming",
'on3':"sunwukong"}
print(infoo.items())#把自己转换成列表
#[('on1', '张家辉'), ('on2', 'xuwuming'), ('on3', 'sunwukong')]
enumerate
kl=['alex','jack','tadd','moth']kl[1]='end'
for i,j in enumerate(kl): #同时输出 标识与元素
print(i,j)
#0 alex
#1 end
#2 tadd
#3 moth
相关文章推荐
- python中列表,元组,字典,字符串相互转换
- 字符串、列表、元组、字典、集合的区别
- Python字符串、列表、字典、元组互转
- Python基础02--(数字,字符串,列表,元组,字典)
- python字符串/元组/列表/字典互转
- Python学习笔记ucas(lecture2)数据结构(字符串、列表、元组、字典、集合)
- Python列表(list)、字典(dict)、字符串(string)基本操作小结
- Python基础(二)——字符串、列表、元组、字典
- python 中list(列表),tupe(元组),str(字符串),dict(字典)之间的相互转换
- python 学习笔记-山寨携程(列表,字符串,字典和流程控制总结)
- Python字符串、元组、列表、字典互相转换的方法
- 字符串,元组,列表,字典之间的拼接
- 给定一个字符串列表,找出单词中最长单词,可以用l列表中的其他单词一次构建一个字符。返回具有最小字典顺序的最长单词。
- 字符串、列表、字典、元组
- Python 列表(list)、字典(dict)、字符串(string)常用基本操作小结
- 简明python教程 --C++程序员的视角(四):容器类型(字符串、元组、列表、字典)和参考
- 002第一部分_[字典/列表解析/字符串操作/STR与BYTES的区别]
- 3.字符串、列表、元组、字典、集合的补充
- [python 笔记2]列表、字符串、字典(list?string?map?)
- 元组、列表、字典、字符串的遍历