<jupyter_start><jupyter_text>简介  属性 attributes 属性是与对象绑定的一组数据，可以只读，只写，或者读写，使用时不加括号，例如：<jupyter_code>f = file("new_file", 'w')<jupyter_output><empty_output><jupyter_text>显示模式属性：<jupyter_code>f.mode<jupyter_output><empty_output><jupyter_text>是否关闭：<jupyter_code>f.closed<jupyter_output><empty_output><jupyter_text>`mode` 是只读属性，所以这样会报错：<jupyter_code>f.mode = 'r'<jupyter_output><empty_output><jupyter_text>获取属性不需要加括号：<jupyter_code>f.mode()<jupyter_output><empty_output><jupyter_text>方法 method 方法是与属性绑定的一组函数，需要使用括号，作用于对象本身：<jupyter_code>f.write('Hi.\n')
f.seek(0)
f.write('Hola!\n')
f.close()
!rm new_file<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16534181240063592, 'fraction_numerical': 0.001589825119236884, 'mean_word_length': 20.724137931034484, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '489711', 'license': 'MIT', 'n_tokens_mistral': 352, 'n_tokens_neox': 369, 'n_words': 15, 'path': 'lijin-THU:notes-python/08-object-oriented-programming/08.01-oop-introduction.ipynb', 'repo_name': 'Maecenas/python-getting-started', 'size': '629'}