2017-06-19 3 views
0
[email protected]:~$ 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 

Die Datei /home/debian8/.mozilla/firefox/3usaclqf.default/lock ist ein Link.Warum FileNotFoundError: [Errno 2] Keine solche Datei oder Verzeichnis?

[email protected]:~$ 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' 

Warum os.stat nicht Infos auf file2 bekommen?

Antwort

2

Ist die Datei, um sie verknüpft ist zu existieren? os.stat() folgt Symlinks. Wenn Sie die Link-Datei setzen möchten, benötigen Sie os.lstat()

-1

Vielleicht haben Sie nicht die Berechtigung, diese file.try zu öffnen sudo chmod 777 /home/debian8/.mozilla/firefox/3usaclqf.default/lock

+0

Es ist bereits im 777-Status. –

Verwandte Themen