Home > Article > Backend Development > 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!