os.sendfile() in Python is used to copy a specified number of bytes from a specified source file descriptor to the specified file descriptor dest, starting at the specified offset.
This method returns the total number of bytes sent, and if EOF (end of file) is reached, it returns 0.
Syntax: os.sendfile (dest, source, offset, count)
dest: A file descriptor representing destination file.
source: A file descriptor representing source file
offset: An integer value representing starting position. Bytes to be sent will be counted from this position.
count: An integer value denoting total number of bytes to be sent from source file descriptor.
Return Type: This method returns an integer value which represents the total of bytes sent from source file descriptor to dest file descriptor. 0 is returned if EOF is reached.
Consider the text below as the contents of a file named & # 39; Python_intro.txt & # 39; .
Python is a widely-used general-purpose, high-level programming language. It was initially designed by Guido van Rossum in 1991 and developed by Python Software Foundation. It was mainly developed for emphasis on code readability, and its syntax allows programmers to express concepts in fewer lines of code. Python is a programming language that lets you work quickly and integrate systems more efficiently.
Code: using the
os.sendfile method ()
100 bytes sent / copied success fully. b’Python is a widely used general-purpose, high level programming language. It was initially designed ’