home PYTHONJAVA
 

open(file, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)

Parameter Description:

  • file: Required, document way (relative or total path)。
  • mode: Optional, document open mode
  • buffering: Set buffer
  • encoding: 一Set buffer
  • errors: Error level
  • newline: Distinguish line breaks
  • closefd: Incoming document parameter type
  • opener:
The

mode parameter is:

ModeDescription
tText mode (default).
xWrite mode, make another document, and report a blunder if the record as of now exists.
bbinary mode.
+Open a document for refreshing (clear and writable).
UUniversal Wrap Mode (not suggested).
rOpen the document as read-as it were. The pointer to the document will be put toward the start of the record. This is the default mode.
rbOpens a record in twofold organization for read-as it were. The record pointer will be put toward the start of the document. This is the default mode. By and large utilized for non-content documents, for example, pictures.
r+Open a record for perusing and composing. The document pointer will be set toward the start of the record.
rb+Open a document in twofold organization for perusing and composing. The document pointer will be set toward the start of the record. By and large utilized for non-content records, for example, pictures.
wOpen a document for composing as it were. On the off chance that the record as of now exists, open the document and begin altering from the earliest starting point, ie the first substance will be erased. In the event that the record does not exist, make another one.
wbOpen a document in double configuration for composing as it were. On the off chance that the record as of now exists, open the document and begin altering from the earliest starting point, ie the first substance will be erased. On the off chance that the document does not exist, make another one. For the most part utilized for non-content records, for example, pictures.
w+Open a record for perusing and composing. In the event that the document as of now exists, open the record and begin altering from the earliest starting point, ie the first substance will be erased. In the event that the record does not exist, make another one.
wb+Opens a document in twofold organization for perusing and composing. On the off chance that the record as of now exists, open the document and begin altering from the earliest starting point, ie the first substance will be erased. In the event that the document does not exist, make another one. By and large utilized for non-content records, for example, pictures.
aOpen a document for annexing. On the off chance that the record as of now exists, the document pointer will be put toward the finish of the record. As such, the new substance will be kept in touch with the current substance. In the event that the document does not exist, make another record for composing.
abOpens a document in double configuration for attaching. In the event that the record as of now exists, the document pointer will be set toward the finish of the document. At the end of the day, the new substance will be kept in touch with the current substance. On the off chance that the record does not exist, make another document for composing.
a+Open a document for perusing and composing. In the event that the record as of now exists, the document pointer will be put toward the finish of the document. Affix mode will be utilized when the record is opened. On the off chance that the document does not exist, make another record for perusing and composing.
ab+Open a document in double arrangement for affixing. On the off chance that the record as of now exists, the document pointer will be set toward the finish of the document. In the event that the record does not exist, make another document for perusing and composing.

The default is text mode, if you want to open in binary mode, add b .

file object

The file object is created using the open function, and the following table lists the functions commonly used by the file object:






welookups is optimized for learning.© welookups. 2018 - 2019 All Right Reserved and you agree to have read and accepted our term and condition.