[英]Why FileNotFoundError: [Errno 2] No such file or directory?
debian8@debian:~$ ls -al /home/debian8/.mozilla/firefox/3usaclqf.default/lock
lrwxrwxrwx 1 debian8 debian8 15 Jun 19 18:58 /home/debian8/.mozilla/firefox/3usaclqf.default/lock -> 127.0.1.1:+2815
The file /home/debian8/.mozilla/firefox/3usaclqf.default/lock
is a link. 文件
/home/debian8/.mozilla/firefox/3usaclqf.default/lock
是一个链接。
debian8@debian:~$ python
Python 3.6.1 |Anaconda 4.4.0 (64-bit)| (default, May 11 2017, 13:09:58)
>>> import os
>>> file1="/tmp/.X0-lock"
>>> print(os.stat(file1))
os.stat_result(st_mode=33060, st_ino=8126472, st_dev=2050, st_nlink=1, st_uid=0, st_gid=0, st_size=11, st_atime=1497877067, st_mtime=1497868886, st_ctime=1497868886)
>>> file2="/home/debian8/.mozilla/firefox/3usaclqf.default/lock"
>>> print(os.stat(file2))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
FileNotFoundError: [Errno 2] No such file or directory: '/home/debian8/.mozilla/firefox/3usaclqf.default/lock'
Why os.stat
can't get infos on file2? 为什么
os.stat
无法获得有关file2的信息?
Does the file it is linked to exist? 链接到的文件是否存在? os.stat() follows symlinks.
os.stat()遵循符号链接。 If you want to stat the link file, you need os.lstat()
如果要统计链接文件,则需要os.lstat()
也许您无权打开此文件。尝试sudo chmod 777 /home/debian8/.mozilla/firefox/3usaclqf.default/lock
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.