descriptor_instance=MyDescriptor() 当我们运行该代码时,会遇到TypeError: Descriptors cannot be created directly的异常。 二、可能出错的原因 导致TypeError: Descriptors cannot be created directly报错的原因主要有以下几点: 直接实例化描述器:描述器类通常应作为类属性使用,而不是直接实例化。这是因为描述器需要绑定...
当遇到“TypeError: Descriptors cannot not be created directly”这一错误时,意味着你尝试以错误的方式使用了描述符。记住,描述符应该作为类属性来定义,并通过包含它们的类的实例来触发其行为。正确地理解和应用描述符的概念,可以在Python中实现更加灵活和强大的对象属性管理。希望本文能帮助你理解和解决描述符使用中遇...
1. 报错信息 TypeError: Descriptors cannot not be created directly. If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0. 2. 解决方案 点击ternimal输入pip uninstall protobuf将现有版本的卸载,然后输入pip install protobuf 3.19...
“TypeError: Descriptors cannot not be created directly”主要是由于错误地使用描述符导致的。正确的方式是将描述符作为类属性而不是直接实例化它们。错误使用的本质是违反了描述符用法的基本原则。 一个常见的错误示例: classMyDescriptor:def__get__(self,instance,owner):# 实现相关逻辑 pass # 尝试直接创建描述...
TypeError: "descriptors cannot be created directly" 的含义 在Python中,当你看到 TypeError: descriptors cannot be created directly 这个错误时,它通常意味着你试图直接实例化一个描述符(descriptor)对象,而不是通过其所属的类或实例来访问它。描述符是Python中一个高级特性,它允许你控制属性的访问(包括获取、设置...
TypeError: Descriptors cannot not be created directly. If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0. If you cannot immed…
“TypeError: Descriptors cannot not be created directly”主要是由于错误地使用描述符导致的。正确的方式是将描述符作为类属性而不是直接实例化它们。错误使用的本质是违反了描述符用法的基本原则。 一个常见的错误示例: class MyDescriptor: def __get__(self, instance, owner): ...
僕の音楽なんかこの世になくたっていいんだよ Everybody don't know why. Everybody don't know why. Everybody don't know much. 僕は気にしない 君は気付かない 何処にももういないいない Everybody don't know why. Everybody don't know why. ...
in <module> serialized_options=None, file=DESCRIPTOR), File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/google/protobuf/descriptor.py", line 561, in __new__ _message.Message._CheckCalledFromGeneratedFile() TypeError: Descriptors cannot not be created directly. ...
TypeError: Descriptors cannot not be created directly这个异常并不是 Python 标准库中的常见异常信息,但它通常与描述符(descriptors)的使用相关。在 Python 中,描述符是一种具有特殊方法的对象属性,这些方法允许描述符对象控制对其值的访问、修改以及可能的其他操作。