小白教程
所有教程
关于
Search
172.70.130.73
172.70.130.73
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Python3 os isatty”的源代码
本页内容
上一节:
Python3_os_getcwdb
下一节:
Python3_os_lchflags
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:os.isatty(fd)}}[[Category:python3 os file methods|23]] = Python3 os.isatty() 方法 = [[python3 os file methods|Python3 OS 文件/目录方法]] === 概述 === os.isatty() 方法用于判断如果文件描述符fd是打开的,同时与tty(-like)设备相连,则返回true, 否则False。 === 语法 === '''isatty()'''方法语法格式如下: <sample title="" desc="" lang="python" hererun="1"> os.isatty() </sample> === 参数 === * 无 === 返回值 === 如果文件描述符fd是打开的,同时与tty(-like)设备相连,则返回true, 否则False。 == 以下实例演示了 isatty() 方法的使用: <sample title="" desc="" lang="python" hererun="1"> #!/usr/bin/python3 import os, sys # 打开文件 fd = os.open( "foo.txt", os.O_RDWR|os.O_CREAT ) # 写入字符串 str = "This is xiaobai.wang site" os.write(fd,bytes(str, 'UTF-8')) # 使用 isatty() 查看文件 ret = os.isatty(fd) print ("返回值: ", ret) # 关闭文件 os.close( fd ) </sample> 执行以上程序输出结果为: <sample title="" desc="" lang="python" hererun="1"> 返回值: False </sample> [[python3 os file methods|Python3 OS 文件/目录方法]]
返回至“
Python3 os isatty
”。
上一节:
Python3_os_getcwdb
下一节:
Python3_os_lchflags