首页 > 其他 > 详细

如何访问私有方法

时间:2015-10-16 10:06:43      阅读:294      评论:0      收藏:0      [点我收藏+]
# -*- coding: utf-8 -*-
#python 27
#xiaodeng
#如何访问私有方法


class Securityp(object):
    
    def __my(self):
        print "Bet you can‘t see me..."

b=Securityp()
print dir(b) #打印出所有的方法和属性等信息
print b.__dict__  #没有打印结果
b._Securityp__my()
‘‘‘
[‘_Securityp__my‘, ‘__class__‘, ‘__delattr__‘, ‘__dict__‘, ‘__doc__‘, ‘__format__‘, ‘__getattribute__‘, ‘__hash__‘, ‘__init__‘, ‘__module__‘, ‘__new__‘, ‘__reduce__‘, ‘__reduce_ex__‘, ‘__repr__‘, ‘__setattr__‘, ‘__sizeof__‘, ‘__str__‘, ‘__subclasshook__‘, ‘__weakref__‘]
{}
Bet you can‘t see me...
‘‘‘

 

如何访问私有方法

原文:http://www.cnblogs.com/dengyg200891/p/4884291.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!