Python抱怨“ntpath”中没有expanduser,即使我导入了os.path

Python抱怨“ntpath”中没有expanduser,即使我导入了os.path,python,Python,我怎么能做到 Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:18:55) [MSC v.1900 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import os.path >>> print(os.path) <module 'ntpath' f

我怎么能做到

Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:18:55) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os.path
>>> print(os.path)
<module 'ntpath' from 'C:\\Users\\odin\\AppData\\Local\\Programs\\Python\\Python35\\lib\\ntpath.py'>
>>> os.path.expanduser('~')
'C:\\Users\\odin'
最小脚本示例:

import os.path

with open(os.path.join(os.path.expanderuser('~'),'DirectoryMonitorScript','log','ScriptLog.txt'),'a') as f:
    # Do nothing
    print('Nothing...')
这是在Windows10上。不确定我还可以提供哪些其他详细信息。

是输入错误:AttributeError:module“ntpath”没有属性“expanderuser”

这不应该是你的吗

import os.path

with open(os.path.join(os.path.expanderuser('~'),'DirectoryMonitorScript','log','ScriptLog.txt'),'a') as f:
    # Do nothing
    print('Nothing...')