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

前端 未结 7 551
别那么骄傲
别那么骄傲 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:12

    os.open() method opens the file file and set various flags according to flags and possibly its mode according to mode.

    The default mode is 0777 (octal), and the current unmask value is first masked out.

    This method returns the file descriptor for the newly opened file.

    While,

    io.open() method opens a file, in the mode specified in the string mode. It returns a new file handle, or, in case of errors, nil plus an error message.

    Hope this helps

提交回复
热议问题