What's the difference between io.open() and os.open() on Python?

前端 未结 7 556
别那么骄傲
别那么骄傲 2020-11-30 05:34

I realised that the open() function I\'ve been using was an alias to io.open() and that importing * from os would oversha

7条回答
  •  孤街浪徒
    2020-11-30 06:08

    Absolutely everything:

    • os.open() takes a filename as a string, the file mode as a bitwise mask of attributes, and an optional argument that describes the file permission bits, and returns a file descriptor as an integer.

    • io.open() takes a filename as a string or a file descriptor as an integer, the file mode as a string, and optional arguments that describe the file encoding, buffering used, how encoding errors and newlines are handled, and if the underlying FD is closed when the file is closed, and returns some descendant of io.IOBase.

提交回复
热议问题