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

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

    Database and system application developers usually use open instead of fopen as the former provides finer control on when, what and how the memory content should be written to its backing store (i.e., file on disk).

    In Unix-like operating system, open is used to open regular file, socket end-point, device, pipe, etc. A positive file descriptor number is returned for every successful open function call. It provides a consistent API and framework to check for event notification, etc on a variety of these objects.

    However, fopen is a standard C function and is normally used to open regular file and return a FILE data structure. fopen, actually, will call open eventually. fopen is good enough for normal usage as developers do not need to worry when to flush or sync memory content to the disk and do not need event notification.

    0 讨论(0)
提交回复
热议问题