← 返回列表

Python3 os 模块 Isatty 方法

Python3 os 模块 Isatty 方法 #!/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 )

Python3 os 模块 Isatty 方法

#!/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 )

打开资源 ↗

交流与评论