Home > Backend Development > Python Tutorial > How to switch folders in python

How to switch folders in python

爱喝马黛茶的安东尼
Release: 2019-06-18 11:12:51
Original
4361 people have browsed it

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")
Copy after login

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

>>> import kNN
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template