奇怪了,我的《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

相关文章:

  • 2021-05-12
  • 2021-08-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-07
  • 2021-11-22
猜你喜欢
  • 2022-12-23
  • 2021-08-28
  • 2021-11-17
  • 2021-10-31
  • 2021-11-07
  • 2021-07-15
  • 2022-12-23
相关资源
相似解决方案