Get your
own Python
server
×
Change Orientation
Change Theme, Dark/Light
Go to Spaces
#Import os Library import os #open a file and create a file descriptor fd = os.open("test.txt", os.O_RDWR|os.O_CREAT) #Duplicate File descriptor duplicateFd = os.dup(fd) #print both descriptors print("Orignal file descriptor:", fd) print("Duplicate file descriptor:", duplicateFd) #close file os.close(fd) os.close(duplicateFd)
Original file descriptor: 4
Duplicate file descriptor: 5