如果 Python 对象是“可下标的",这意味着什么?或不? [英] What does it mean if a Python object is "subscriptable" or not?
本文介绍了如果 Python 对象是“可下标的",这意味着什么?或不?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
哪些类型的对象属于可订阅"的领域?
Which types of objects fall into the domain of "subscriptable"?
推荐答案
基本上意味着对象实现了 __getitem__()
方法.换句话说,它描述了作为容器"的对象,这意味着它们包含其他对象.这包括字符串、列表、元组和字典.
It basically means that the object implements the __getitem__()
method. In other words, it describes objects that are "containers", meaning they contain other objects. This includes strings, lists, tuples, and dictionaries.
这篇关于如果 Python 对象是“可下标的",这意味着什么?或不?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文