本文介绍了Python os.path是ntpath,怎么办?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人可以告诉我Python如何将os.path
别名为ntpath
吗?
Can someone tell me how Python "aliases" os.path
to ntpath
?
>>> import os.path
>>> os.path
<module 'ntpath' from 'C:\Python26\lib\ntpath.pyc'>
>>>
推荐答案
查看 os.py ,第55-67行:
Look at os.py, lines 55-67:
elif 'nt' in _names:
name = 'nt'
linesep = '\r\n'
from nt import *
try:
from nt import _exit
except ImportError:
pass
import ntpath as path
import nt
__all__.extend(_get_exports_list(nt))
del nt
import ntpath as path
是导致os.path
在您的平台(无疑是Windows)上为ntpath
的特定语句.
The import ntpath as path
is the specific statement that causes os.path
to be ntpath
on your platforms (doubtlessly Windows).
这篇关于Python os.path是ntpath,怎么办?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!