Python3 File isatty () method
Outline
Areisatty () method to detect file is connected to a terminal device, if it is to return True, otherwise False.
grammar
isatty () method has the following syntax:
fileObject.isatty();
parameter
no
return value
If connected to a terminal device returns True, otherwise False.
Examples
The following example demonstrates isatty () method of use:
#!/usr/bin/python3 # 打开文件 fo = open("w3big.txt", "wb") print ("文件名为: ", fo.name) ret = fo.isatty() print ("返回值 : ", ret) # 关闭文件 fo.close()
The above example output is:
文件名为: w3big.txt 返回值 : False