小马爱乐容 发表于 2022-11-6 20:46:27

求大佬汇总 点操作符 的所有应用情况


如图!

Python初学者求各位大佬汇总Python语言中,点操作符的所有应用情况!什么时候用点连接前后,越详细越全面越好。

希望能有真正的大佬给出详细的逻辑原理解读。

{:5_108:}

tommyyu 发表于 2022-11-6 20:46:28

就是表示某一个对象的某一个属性或者方法,使用点操作符的时候会调用__getattr__()魔法方法

tommyyu 发表于 2022-11-6 22:10:18

在 python 的交互模式中输入 help('.') 即可得到Attribute references
********************

An attribute reference is a primary followed by a period and a name:

   attributeref ::= primary "." identifier

The primary must evaluate to an object of a type that supports
attribute references, which most objects do.This object is then
asked to produce the attribute whose name is the identifier.This
production can be customized by overriding the "__getattr__()" method.
If this attribute is not available, the exception "AttributeError" is
raised.Otherwise, the type and value of the object produced is
determined by the object.Multiple evaluations of the same attribute
reference may yield different objects.

Related help topics: getattr, hasattr, setattr, ATTRIBUTEMETHODS, FLOAT,
MODULES, OBJECTS

jackz007 发表于 2022-11-6 22:37:18

汇总 点操作符 的所有应用情况
      大家都不懂,但是,都在精彩地使用,这个世界恐怕只有阁下才会有这样的好奇心。

嘉岳呀 发表于 2022-11-7 13:29:41

An attribute reference is a primary followed by a period and a name:

   attributeref ::= primary "." identifier

The primary must evaluate to an object of a type that supports
attribute references, which most objects do.This object is then
asked to produce the attribute whose name is the identifier.This
production can be customized by overriding the "__getattr__()" method.
If this attribute is not available, the exception "AttributeError" is
raised.Otherwise, the type and value of the object produced is
determined by the object.Multiple evaluations of the same attribute
reference may yield different objects.

Related help topics: getattr, hasattr, setattr, ATTRIBUTEMETHODS, FLOAT,
MODULES, OBJECTS

意思是(机翻):

属性引用是一个主属性,后面跟着一个句号和一个名称:

Attributeref::=主“.”标识符

主对象必须求值为支持
属性引用,这是大多数对象所做的。这个对象是
要求生成名称为标识符的属性。这
可以通过重写“__getattr__()”方法来定制产品。
如果此属性不可用,则异常“AttributeError”是可用的
提高。否则,生成的对象的类型和值为
由物体决定。同一属性的多个求值
引用可以产生不同的对象。

相关帮助主题:getattr, hasattr, setattr, ATTRIBUTEMETHODS, FLOAT,
模块、对象
页: [1]
查看完整版本: 求大佬汇总 点操作符 的所有应用情况