Get your
own Python
server
×
Change Orientation
Change Theme, Dark/Light
Go to Spaces
# import os Library import os # open file fd = os.open( "file.txt", os.O_RDWR|os.O_CREAT ) # Print value of file descriptor print("Original file descriptor:", fd) # Duplicate file descriptor dup_fd = 9 os.dup2(fd, dup_fd) # Print value of duplicate file descriptor print("Duplicated file descriptor:", dup_fd) # Close file descriptors os.close(fd) os.close(dup_fd)
Original file descriptor: 4
Duplicated file descriptor: 9