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.sendfile() method in Python is used to copy specified number of bytes from specified source file descriptor to specified dest file descriptor starting from 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 below text as the content of the file named ‘Python_intro.txt’.
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.
100 bytes sent/copied successfully. b'Python is a widely used general-purpose, high level programming language. It was initially designed '
- class method vs static method in Python
- Python | set() method
- Python | os.dup() method
- Python | next() method
- Python | os.WEXITSTATUS() method
- Python | sympy.has() method
- Python | os.abort() method
- Python | sympy.lcm() method
- Python | Tensorflow log() method
- Python | os._exit() method
- Python PIL | putalpha() Method
- Python PIL | putdata() method
- Python PIL | getcolors() Method
- Python PIL | ImageOps.fit() method
- Python | os.mkdir() 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 email@example.com. 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.