iswbm / magic-python

Python 黑魔法手册
http://magic.iswbm.com/
3.32k stars 478 forks source link

3.11节小问题 #21

Closed desertstsung closed 3 years ago

desertstsung commented 3 years ago

3.9.2下,io.open和open应该是一个函数,os.open才应该是底层的文件I/O流

Python 3.9.2 (default, Feb 28 2021, 17:03:44) 
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> (open1:=open) is (open2:=os.open)
False
>>> import io
>>> (open3:=open) is (open3:=io.open)
True
iswbm commented 3 years ago

感谢指正,已更新补充!