os.isatty( fd )
fd -- 這是需要關聯檢查的檔案描述符。
#!/usr/bin/python3 import os, sys # Open a file fd = os.open( "foo.txt", os.O_RDWR|os.O_CREAT ) # Write one string line="This is test" b=line.encode() os.write(fd, b) # Now use isatty() to check the file. ret = os.isatty(fd) print ("Returned value is: ", ret) # Close opened file os.close( fd )
Returned value is: False