摘要: 会输出以下内容: [Errno 2] No such file or directory: '1.txt' 打开文件可能会抛出IOError,我们定义一个msg变量来接受错误信息并打印出来。 以下是常见错误类型 阅读全文
posted @ 2017-02-13 12:10 hutzerg 阅读(146) 评论(0) 推荐(0) 编辑
摘要: class Test(object): x = 11 def __init__(self, _x): self._x = _x print("Test.__init__") @classmethod def class_method(cls): # 类方法 print("class_method") ... 阅读全文
posted @ 2017-02-13 11:40 hutzerg 阅读(156) 评论(0) 推荐(0) 编辑
摘要: strip,strip,lstrip三个函数主要用于移除字串中的满足条件的字符,传入参数是一个字符数组,它们分别表示匹配并去掉右边、两边、左边的字符。 当没有参数传入时,strip()表示去除首尾空格,其它两个函数同理。 code: >>> str = '\tgood to say you,you 阅读全文
posted @ 2017-02-13 11:22 hutzerg 阅读(157) 评论(0) 推荐(0) 编辑