# 1、检索文件夹大小的程序,要求执行方式如下 # python3.8 run.py 文件夹 import os,sys l = sys.argv[1] size = 0 def get_size(file_paths): global size for file in os.listdir(file_paths): file_path = os.path.join(file_paths, file) if os.path.isfile(file): size += os.path.getsize(file_path) elif os.path.isdir(file): get_size(file_path) return size get_size(l) print(size)
import random def make_code(size): res = "" for i in range(size): s1 = chr(random.randrange(65,90)) s2 = str(random.randint(0,9)) res += random.choice([s1,s2]) return res