首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > perl python >

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

2012-03-20 
Python 奇遇,求大牛解释Python codezwx@Mac:~/code/python/shell_command$ pythonPython 2.6.2 (release26

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。

热点排行