2016年12月13日

python运算符重载

摘要: python运算符重载就是在解释器使用对象内置操作前,拦截该操作,使用自己写的重载方法。 重载方法:__init__为构造函数,__sub__为减法表达式 其他重要的还有(省去前后的__): del析构函数, add加法表达式, or, repr打印(print), str转化(str), call 阅读全文

posted @ 2016-12-13 17:50 LebronZhang 阅读(182) 评论(0) 推荐(0)

Python文件读取

摘要: f = open(path, 'w') f.write(self.str) f.close() IOError: [Errno 13] Permission denied: 'output.txt' 没有权限写文件,比较蠢的解决方法 sudo chmod 777 <file_name> 阅读全文

posted @ 2016-12-13 15:04 LebronZhang 阅读(99) 评论(0) 推荐(0)

导航