YouTip LogoYouTip

Os Write

# Python2.x Python os.write() Method [![Image 3: Python File Methods](#) Python OS File/Directory Methods](#) * * * ### Overview The os.write() method is used to write a string to the file descriptor fd. It returns the actual length of the string written. Available in Unix. ### Syntax The syntax format of the **write()** method is as follows: os.write(fd, str) ### Parameters * **fd** -- File descriptor. * **str** -- The string to write. ### Return Value This method returns the actual number of bits written. ### Example The following example demonstrates the use of the write() method: #!/usr/bin/python# -*- coding: UTF-8 -*-import os, sys # Open file fd = os.open("f1.txt",os.O_RDWR|os.O_CREAT)# write string ret = os.write(fd,"This is .com site")
← C Basic SyntaxOs Walk β†’