在Python中调用Linux文件夹通常涉及以下步骤:
获取当前工作目录
```python
import os
current_directory = os.getcwd()
print(current_directory) 打印当前工作目录
创建新文件夹
```python
import os
import time
获取当前时间并格式化
folder_name = time.strftime("%Y-%m-%d_%H-%M-%S", time.localtime())
创建新文件夹
new_folder_path = os.path.join(current_directory, folder_name)
os.makedirs(new_folder_path)
print(new_folder_path) 打印新创建的文件夹路径
更改当前工作目录
```python
import os
更改当前工作目录
new_directory = "/path/to/your/directory"
os.chdir(new_directory)
print(os.getcwd()) 打印新的当前工作目录
分解路径
```python
import os
分解路径为目录名和文件名
path = "/path/to/your/file.txt"
directory, filename = os.path.split(path)
print("Directory:", directory)
print("Filename:", filename)