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