Home  >  Article  >  Backend Development  >  How to open a folder in python

How to open a folder in python

藏色散人
藏色散人Original
2019-10-15 11:11:0511176browse

How to open a folder in python

How to open a folder in python?

Use the following command

import os
os.system('explorer.exe /n, 文件夹路径')

This way you can open it directly. To open a file, I don’t know if you want to read it in the program or open the file directly. To open the file, use

os.system('cmd /c 文件名')

To use the file content in the script, use the open function to read the file content.

Related recommendations: "Python Tutorial"

The above is the detailed content of How to open a folder 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