io.open()
is the preferred, higher-level interface to file I/O. It wraps the OS-level file descriptor in an object that you can use to access the file in a Pythonic manner.
os.open()
is just a wrapper for the lower-level POSIX syscall. It takes less symbolic (and more POSIX-y) arguments, and returns the file descriptor (a number) that represents the opened file. It does not return a file object; the returned value will not have read()
or write()
methods.
From the os.open()
documentation:
This function is intended for low-level I/O. For normal usage, use the built-in function open()
, which returns a “file object” with read()
and write()
methods (and many more).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…