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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM