一.运用File类实现获取指定目录下文件夹和文件对象 1.File类 2.方法: 获取文件绝对路径 :getAbsolutePath 案例: import java.io.File; /** * 获取指定目录下文件夹和文件对象 * Created by lcj on 2017/11/7. */ public class fileTest03 { public static void main(String[] args) { File dirr = new File("D:\\xuexizili
du -ah --max-depth=1 这个是我想要的结果 a表示显示目录下所有的文件和文件夹(不含子目录),h表示以人类能看懂的方式,max-depth表示目录的深度. du命令用来查看目录或文件所占用磁盘空间的大小.常用选项组合为:du -sh 一.du的功能:`du` reports the amount of disk space used by the specified files and for each subdirectory (of directory argum
代码: import os path = r"C:\Users\Administrator\Desktop\***" print('filenum:',len([lists for lists in os.listdir(path) if os.path.isfile(os.path.join(path, lists))]))
#法一 import os path = "C://Python34//" for file in os.listdir(path): if os.path.isfile(os.path.join(path,file))==True: if file.find('.')<0: newname=file+'.jpg' os.rename(os.path.join(path,file),os.path.join(path,newname)) #法二 import os import