摘要:
import osdef func(path): if os.path.isfile(path): if path.endswith(".py"): os.system("python %s" % path) elif os.path.isdir(path): list_num = os.listd 阅读全文
摘要:
递归: def list_in(s): result = 0 lst = os.listdir(s) for i in lst: i = s + "/" + i if os.path.isfile(i): result = result + os.path.getsize(i) elif os.pa 阅读全文
摘要:
import osusername = input("请输入用户名:")password = input("请输入密码:")lst = os.listdir()if "alex" in lst: print("文件已存在!")else: if username == "alex" and passw 阅读全文
摘要:
import sysusername = sys.argv[1]password = sys.argv[2]if username == "alex" and password == "123465": print("Congratulation")else: exit() 阅读全文
摘要:
import timetime1 = "2019-08-01 19:32:02"time2 = "2020-01-02 18:21:31"struct_time1 = time.strptime(time1, "%Y-%m-%d %H:%M:%S")struct_time2 = time.strpt 阅读全文
摘要:
import randomdef func(a=6, alpha=True): s = "" for i in range(a): num = str(random.randint(0, 9)) if alpha: alpha_upper = chr(random.randint(65, 90)) 阅读全文
摘要:
import osdef func(filepath, n): file = os.listdir(filepath) for f in file: file_p = os.path.join(filepath, f) if os.path.isdir(file_p): print("\t"* n, 阅读全文
摘要:
num = int(input("请输入整数:"))lst = []count = num-1for i in range(1, num*2): if i% 2 != 0: s = " ".join("*" * i).strip(" ") lst.append(s)while count >= 0: 阅读全文
摘要:
lst = [1,2,3,4,5,6,7,8,9]for i in lst: a = 1 line = "" while a <= i: line = line + " " + "%d*%d=%d" % (i , a, i*a) a = a + 1 print(line.strip(" ")) fo 阅读全文
摘要:
def func(*arg): sum = "" for i in arg: sum = sum + str(i) + "_" sum = sum.strip("_") return sumprint(func([1,"alex", "wusie"])) 阅读全文