Python学习笔记(14) --Python IDLE或shell中切换路径

xiaoxiao2021-02-28  92

原文链接:http://blog.csdn.net/garfielder007/article/details/50808015

在Python自带的编辑器IDLE中或者Python shell中不能使用cd命令,那么跳到目标路径呢。

方法是使用os包下的相关函数实现路径切换功能。

[python]  view plain  copy import os   os.getcwd() #获取当前路径   os.chdir("D:\\test"#跳到目标路径下   os.chdir('D:\\test'#单引号、双引号都可以
转载请注明原文地址: https://www.6miu.com/read-57037.html

最新回复(0)