社区
脚本语言
帖子详情
关于Python中dictionary中关键字问题
yjgx007
2008-04-02 11:26:52
为什么list不能作为关键字,tuple可以呢?
这里涉及到immutable概念, 只有不可变的对象能够成为关键字,list是可变的.
...全文
95
1
打赏
收藏
关于Python中dictionary中关键字问题
为什么list不能作为关键字,tuple可以呢? 这里涉及到immutable概念, 只有不可变的对象能够成为关键字,list是可变的.
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
1 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
ChumpKlutz
2008-04-02
打赏
举报
回复
list是可变对象所以不成作为key
RuntimeError:
dictionary
changed size during iteration
RuntimeError:
dictionary
changed size during iteration i 遍历字典
关键字
for i in user_trust.keys(): nodes, nodes1, nodes2, nodes3, nodes4, nodes5, nodes6 = devide_into_6(user_trust, i) score = trust_...
python
dictionary
函数_
python
学习之
dictionary
函数的用法
编写下面这段代码运行出现了报错。#!/usr/bin/env
python
2.7#-*-coding:utf-8 -*-d=['T']a=raw_input('请输入a的值')if a in d :print d[a]else:print d.get(a,'error')报错:请输入a的值fsfTraceback (most recent call last):File "C:/Users/Adm...
python
dictionary
转list_如何将
python
中
的List转化成
dictionary
如何将
python
中
的List转化成
dictionary
问题
1:如何将一个list转化成一个
dictionary
?
问题
描述:比如在
python
中
我有一个如下的list,其
中
奇数位置对应字典的key,偶数位置为相应的value解决方案:1.利用zip函数实现2.利用循环来实现3.利用 enumerate函数生成index来实现
问题
2 我们如何将两个list 转化成一个
dictionary
?
问题
描述:...
Python
中
的List,Tuple和
Dictionary
List 参考:http://www.greenteapress.com/think
python
/thinkCSpy/html/chap08.html List是一组有序的元素,和String有些类似,只是String
中
只能是字符,而List
中
则可以包含任何类型的元素,如下面的例子所示: [10, 20, 30, 40] ["spam", "bungee", "swallow"]
python
中
的
dictionary
_科学网—
python
中
dictionary
的用法小结 - 于博的博文
>>>a=dict(one=1,two=2,three=3)>>>b={'one':1,'two':2,'three':3}>>>c=dict(zip(['one','two','three'],[1,2,3]))>>>d=dict([('two',2),('one',1),('three',3)])>>>e...
脚本语言
37,738
社区成员
34,210
社区内容
发帖
与我相关
我的任务
脚本语言
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
复制链接
扫一扫
分享
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
试试用AI创作助手写篇文章吧
+ 用AI写文章