怎么更改python的默认路径
FXL
2020-08-26 10:36:558432浏览 · 0收藏 · 0评论
可以通过os模块来实现python中路径的更改。
(推荐教程:Python入门教程)
os.chdir() 方法用于改变当前工作目录到指定的路径。如果允许访问返回 True , 否则返回False。
查看默认路径:
>>> import os >>> os.getcwd() 'D:\\Program Files\\Python35'
更改默认路径:
>>> os.chdir("D:\Program Files\Python35\modifyPath\test02") >>> os.getcwd() 'D:\\Program Files\\Python35\\ modifyPath \\ test02
关注公众号,随时随地在线学习
FXL
认证0级讲师