python 之 os.path.expanduser()

 奇怪了,我的《python基础教程第二版》里面写的是

sys.path.expanduser('~/python')

使用后会有如下报错

Traceback (most recent call last):
  File "./info.py", line 6, in <module>
    sys.path.expanduser('~/desktop/')
AttributeError: 'list' object has no attribute 'expanduser'

后来查了一下,发现原来这不是正确的,应该使用下面这个

os.path.expanduser('~/python/')

python版本是2.7

原文地址:https://www.cnblogs.com/tcstory/p/3320001.html