os.write() in Python is used to write a string of bytes to a given file descriptor.
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.
os.write() is intended for low-level operations and should be applied to the file descriptor returned by
os. open () or
Syntax: os.write (fd, str)
fd : The file descriptor representing the target file.
str : A bytes-like object to be written in the file.
Return Type: This method returns an integer value which represents the number of bytes actually written.
Code : using the os.write () method to write a byte string to the given file descriptor.
Number of bytes written: 51 pre>