OS module in Python provides functions for interacting with the operating system. OS comes under Python’s standard utility modules. This module provides a portable way of using operating system dependent functionality.
os.pwrite() method in Python is used to write the specified bytestring to the file associated with the specified file descriptor at the specified position. Any existing value will be overwritten at the specified position.
A file descriptor is small integer value that corresponds to a file that has been opened by the current process. It is used to perform various lower level I/O operations like read, write, send etc.
os.pwrite() method is intended for low-level operation and should be applied to a file descriptor as returned by
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 below text as the content of the file named file.txt.
C, C++, Java, C#, PHP
- class method vs static method in Python
- Python | next() method
- Python | set() method
- Python | os.dup() method
- Python | os.close() method
- Python | sympy.apart() method
- Python | os.chmod method
- Python | sys.getrecursionlimit() method
- Python | os.dup2() method
- Python | os.chroot() method
- Python PIL | eval() method
- Python | os.WIFSTOPPED() method
- Python | os.WTERMSIG() method
- Python | os.WCOREDUMP() method
- Python | os.closerange() method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : Akanksha_Rai