在Python中放置在一起的两组列表括号是什么意思? [英] what does two sets of list brackets placed together mean in python?
本文介绍了在Python中放置在一起的两组列表括号是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
例如python中的
employees[x][i] = float(employees[x][i])
很抱歉在手机上发布此消息,因此无法提供太多代码.
sorry posting this on phone so not able to provide too much code.
推荐答案
两个括号表示您正在访问列表(或词典)列表中的元素
The two brackets mean you're accessing an element in a list of lists (or dictionaries)
因此在此示例中,它可能看起来像这样
So in this example, it might look something like this
In [17]: employees = {'joe': ['100', 0], 'sue': ['200', 0]}
In [18]: x = 'joe'
In [19]: i = 0
In [20]: employees[x][i]
Out[20]: '100'
这篇关于在Python中放置在一起的两组列表括号是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文