互联网技术 / 互联网资讯 · 2024年1月31日

Python内置函数-getattr()函数详细解析

描述

getattR() 函数用于返回一个对象属性值。

语法

以下是 getattR 语法:

getattR(object, naMe[, deFAult])

参数

object — 对象。

naMe — 字符串,对象属性。

deFAult — 默认返回值,如果不提供该参数,在没有对应属性时,将触发 AttRibuteError。

返回值

返回对象属性值。

实例

以下实例展示了 getattR 的使用方法:

云计算开发:Python内置函数-getattr()函数详解

OpenMagic API

Need more than content? Move into the product flow.

If you are here for model access, pricing, developer docs, or the future API console, the dedicated product path now lives on api.openmagic.ai.

登录免费注册