Python中括号的不同含义 [英] Different meanings of brackets in Python
本文介绍了Python中括号的不同含义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我很好奇,Python 编程中 3 个不同的括号是什么意思?不确定我是否正确,但如果我错了,请纠正我:
I am curious, what do the 3 different brackets mean in Python programming? Not sure if I'm correct about this, but please correct me if I'm wrong:
[] - # Normally used for dictionaries, list items
() - # Used to identify params
{} - # I have no idea what this does...
或者如果这些括号可以用于其他目的,欢迎任何建议!谢谢!
Or if these brackets can be used for other purposes, any advice is welcomed! Thanks!
推荐答案
[]
:用于定义可变数据类型 - 列表、列表推导式以及用于索引/查找/切片.()
:定义元组、操作顺序、生成器表达式、函数调用和其他语法.{}
:两种哈希表类型 - 字典和集合.[]
: Used to define mutable data types - lists, list comprehensions and for indexing/lookup/slicing.()
: Define tuples, order of operations, generator expressions, function calls and other syntax.{}
: The two hash table types - dictionaries and sets.
这篇关于Python中括号的不同含义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文