小白教程
所有教程
关于
Search
172.70.178.117
172.70.178.117
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Python3 os lstat”的源代码
本页内容
上一节:
Python3_os_lseek
下一节:
Python3_os_major
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:os.lstat(path)}}[[Category:python3 os file methods|30]] = Python3 os.lstat() 方法 = [[python3 os file methods|Python3 OS 文件/目录方法]] === 概述 === os.lstat() 方法用于类似 stat() 返回文件的信息,但是没有符号链接。在某些平台上,这是fstat的别名,例如 Windows。 === 语法 === '''lstat()'''方法语法格式如下: <sample title="" desc="" lang="python" hererun="1"> os.lstat(path) </sample> === 参数 === * '''path''' -- 要返回信息的文件。 === 返回值 === 返回文件信息。 == 以下实例演示了 lstat() 方法的使用: <sample title="" desc="" lang="python" hererun="1"> #!/usr/bin/python3 import os, sys # 打开文件 path = "/var/www/html/foo.txt" fd = os.open( path, os.O_RDWR|os.O_CREAT ) # 关闭打开的文件 os.close( fd ) # 获取元组 info = os.lstat(path) print ("文件信息 :", info) # 获取文件 uid print ("文件 UID :%d" % info.st_uid) # 获取文件 gid print ("文件 GID :%d" % info.st_gid) </sample> 执行以上程序输出结果为: <sample title="" desc="" lang="python" hererun="1"> 文件信息 : (33261, 3450178L, 103L, 1, 500, 500, 0L, 1238866944, 1238866944, 1238948312) 文件 UID :500 文件 GID :500 </sample> [[python3 os file methods|Python3 OS 文件/目录方法]]
返回至“
Python3 os lstat
”。
上一节:
Python3_os_lseek
下一节:
Python3_os_major