让python类的方法或特性变成私有
2016-01-07 17:04
417 查看
<<Python 基础教程>>
为了让方法或者特性变为私有(从外部无法访问),只要在它们的名字前面加上双下划线:
为了让方法或者特性变为私有(从外部无法访问),只要在它们的名字前面加上双下划线:
class Secretive: def __inaccessible(self): print 'Best you can't see me...' def accessible(self): print 'The secret message is:' self.__inaccessible()
相关文章推荐
- Mac下Python调用C动态库
- 【LEETCODE】77-Combinations [Python]
- Windows Cython 安装
- Python 3 语法小记(一)入门 (print 函数用法总结)
- [Leetcode]@python 65. Valid Number
- 4.6. Defining Functions(定义函数)
- python入门神图
- Python之绘图和可视化
- Python之绘图和可视化
- Python Web-第二周-正则表达式(Using Python to Access Web Data)
- Pycharm和PythonWin——Python IDE杂谈
- [Leetcode]@python 64. Minimum Path Sum
- python 列举所有串口模块
- Python中的tile函数
- Python学习
- python中join在2.X版本中的使用
- [Leetcode]@python 63. Unique Paths II
- 【LEETCODE】74-Search a 2D Matrix [Python]
- python-杨辉三角
- Python: keep strings in double quote as one word when split string to words