2021-01-14
阅读量:
664
在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)
发表评论
暂无数据
推荐帖子
0条评论
0条评论
0条评论

