2025-09-10:仓库迁移
This commit is contained in:
10
5.文件与IO/18.将已有的文件描述符包装为文件对象.pyi
Normal file
10
5.文件与IO/18.将已有的文件描述符包装为文件对象.pyi
Normal file
@@ -0,0 +1,10 @@
|
||||
import os
|
||||
|
||||
if __name__ == "__main__":
|
||||
# open函数除了可以对文件对象进行操作以外,也可以打开一些由系统创建的文件描述符
|
||||
fd = os.open("5.文件与IO/17.try.txt", os.O_WRONLY | os.O_CREAT)
|
||||
|
||||
# 当文件被关闭时,这些由系统创建的IO管道也会随之关闭
|
||||
f = open(fd, 'wt')
|
||||
f.write("ca")
|
||||
f.close()
|
Reference in New Issue
Block a user