Home  >  Article  >  Backend Development  >  How to switch folders in python

How to switch folders in python

爱喝马黛茶的安东尼
爱喝马黛茶的安东尼Original
2019-06-18 10:01:434145browse

python如何切换文件夹?

在python中切换工作目录十分简单,只需要几句话就可以实现了,下面是操作步骤:

How to switch folders in python

相关推荐:《python视频教程

首先,点击菜单栏,搜索IDLE。

How to switch folders in python

打开shell,导入os模块,输入以下代码

>>> import os
>>> os.chdir("F:\\MachineLeaning\\kNN")

通过上面的几句就可以实现在Python shell中切换工作目录。只有将工作目录切换到指定的文件夹下,才可以将相关模块import进来。 
如:

>>> import kNN

The above is the detailed content of How to switch folders in python. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn