python-learn

1. __str__ __iter__ __getitem__ __getattr__

https://www.liaoxuefeng.com/wiki/1016959663602400/1017590712115904

2. @property 可以把方法变成属性来调用,而且可以控制读写性

3. 使用 type() 可以创建一个类

image-20211219222900247

4. 元类 metaclass

https://www.liaoxuefeng.com/wiki/1016959663602400/1017592449371072

5. windows 下在java或者node.js中使用python出现编码问题

可以在脚本中设置编码格式,比如:

1
2
3
4
5
6
# -*- coding: utf-8 -*-
import sys
import io

sys.stdin = io.TextIOWrapper(sys.stdin.buffer, encoding='utf-8')
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')

python-learn
http://47.97.104.205/2024-04-22/PythonLearn/
作者
Rojer Di
发布于
2024年4月22日
许可协议