tuoheng_algN/vodsdk/test/os/test.py

15 lines
734 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""
1.os.rename(原文件名,新的文件名) ——文件重命名
2.os.remove(文件名) ——删除文件
如果不说明路径,则在源代码所在文件夹下寻找,寻找不到会报错。
若想删除指定文件夹下的文件,文件名则需要具体路径,例如 os.remove(r"D:\test_1\文件名"), r防止斜杠发生转义
3.os.mkdir(文件夹名) ——创建文件夹
4.os.rmdir(文件夹名) ——删除文件夹
5.os.getced() ——获取当前目录
6.os.chdir(目录) ——切换目录
7.os.listdir(目录) ——获取当前文件夹下所有的文件或者文件夹,返回一个列表
os.listdir("aa") #获取aa文件夹下的所有文件或文件夹返回一个列表
"""
import os