橘子味的心
标题:Python3 os 模块 Close 方法

Python3 os 模块 Close 方法

#!/usr/bin/python3
import os, sys

# Open a file
fd = os.open( "foo.txt", os.O_RDWR|os.O_CREAT )

# Write one string
line = "this is test"

# string needs to be converted byte object
b = str.encode(line)
os.write(fd, b)

# Close opened file
os.close( fd )

print ("Closed the file successfully!!")

目录

分类