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
- Difference between Method Overloading and Method Overriding in Python
- class method vs static method in Python
- Python | set() method
- Python | next() method
- Python | os.dup() method
- Python PIL | Kernel() method
- Python PIL | putalpha() Method
- Python | os.sched_rr_get_interval() method
- Python | sympy.crt() method
- Python | os.sched_get_priority_max() method
- Python | os.wait() method
- Python PIL | getpalette() Method
- Python PIL | tobytes() Method
- Python PIL | getcolors() Method
- Python PIL | putdata() method
Improved By : Akanksha_Rai