os.pwrite() in Python is used to write a specified test line to a file associated with a specified file descriptor at a specified position. Any existing value will be overwritten at the specified position.
File descriptor — it is a small integer value that corresponds to a file that was opened by the current process. It is used to perform various lower level I / O like read, write, send, etc.
The os.pwrite () method is designed to work low-level and should be applied to the file descriptor returned by
os.open () b > or
Syntax: os.pwrite (fd, str, offset)
fd : A file descriptor representing the file to be written.
str : A bytestring representing the content to be written in the file
offset : An integer value denoting the starting position. File writing will start from this offset value.
Return Type: This method returns an integer value representing the number of bytes actually written. .
Consider the following text as the content of a file named file.txt .
C, C ++, Java, C #, PHP pre>
Code: using the os.pwrite () method