Python os.device_encoding() Method
Example
Find the encoding of the device associated with the file descriptor:
#Import os Library
import os
#Open a file
fd = os.open("file.txt", os.O_RDWR | os.O_CREAT)
#Print the device encoding of fd
print ("Device encoding:", os.device_encoding(fd))
Definition and Usage
The os.device_encoding()
returns the encoding of the device associated with the file descriptor, if it is connected to a terminal.
Note: Available only on some Unix platforms.
Syntax
os.device_encoding(fd)
Parameter Values
Parameter | Description |
---|---|
fd | Required. The file descriptor to check |
Technical Details
Return Value: | A str value, representing the
encoding of the device associated with the file descriptor, if it is connected
to a terminal. If no connection is found, it returns None
|
---|---|
Python Version: | 2.6 |