读书人

Python 奇遇求大牛解释解决思路

发布时间: 2012-03-20 14:01:11 作者: rapoo

Python 奇遇,求大牛解释

Python code
zwx@Mac:~/code/python/shell_command$ pythonPython 2.6.2 (release26-maint, Apr 19 2009, 01:56:41)[GCC 4.3.3] on linux2Type "help", "copyright", "credits" or "license" for more information.>>> import os,stat>>> os.path.islink('/cdrom')True>>> stat.S_ISLNK(os.stat('/cdrom').st_mode)False>>>


[解决办法]
From the python doc:

os.stat(path)

Perform the equivalent of a stat() system call on the given path. (This function follows symlinks; to stat a symlink use lstat().)

os.stat("/cdrom")返回的是"/cdrom"所指向的实际文件的stat,当然不是link。

读书人网 >perl python

热点推荐