小白教程
所有教程
关于
Search
172.70.178.99
172.70.178.99
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Python3 file isatty”的源代码
本页内容
上一节:
Python3_file_fileno
下一节:
Python3_file_next
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:file.isatty()}}[[Category:python3 file methods|4]] = Python3 File isatty() 方法 = [[python3 file methods|Python3 File(文件) 方法]] === 概述 === '''isatty()''' 方法检测文件是否连接到一个终端设备,如果是返回 True,否则返回 False。 === 语法 === isatty() 方法语法如下: <sample title="" desc="" lang="python" hererun="1"> fileObject.isatty(); </sample> === 参数 === * '''无''' === 返回值 === 如果连接到一个终端设备返回 True,否则返回 False。 == 以下实例演示了 isatty() 方法的使用: <sample title="" desc="" lang="python" hererun="1"> #!/usr/bin/python3 # 打开文件 fo = open("xiaobai.txt", "wb") print ("文件名为: ", fo.name) ret = fo.isatty() print ("返回值 : ", ret) # 关闭文件 fo.close() </sample> 以上实例输出结果为: <sample title="" desc="" lang="python" hererun="1"> 文件名为: xiaobai.txt 返回值 : False </sample> [[python3 file methods|Python3 File(文件) 方法]]
返回至“
Python3 file isatty
”。
上一节:
Python3_file_fileno
下一节:
Python3_file_next