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

posted @ 2013-09-13 19:32  花瓣奶牛  阅读(7574)  评论(0编辑  收藏  举报