詹惠儿

2021-01-14   阅读量: 461

Python

在python中怎么查看对象有什么属性?

扫码加入数据分析学习群

问:

在python中怎么查看对象有什么属性?


答:

可以用dir()方法查看,dir()返回与该对象关联的方法和属性列表。

示例如下:

# Python program showing
# a use of dir() function
import math
rk =[1, 2, 3, 4, 5]
# print methods and attributes of rk
print(dir(rk))
rk =(1, 2, 3, 4, 5)
# print methods and attributes of rk
print(dir(rk))
rk ={1, 2, 3, 4, 5}
print(dir(rk))
print(dir(math))


52.1207 1 0 关注作者 收藏

评论(0)


暂无数据

推荐课程

推荐帖子