• 模块作业


    # 1、检索文件夹大小的程序,要求执行方式如下
    # python3
    # .8
    # run.py
    # 文件夹

    #python 3.8 run.py 文件夹
    # import sys,os
    # src = sys.argv[1]
    # res = 0
    #
    # def size_of_file(file):
    # global res
    # for file1 in os.listdir(r"%s "%file):
    # path = os.path.join(file,file1)
    # print(path)
    # if os.path.isfile(path):
    # res += os.path.getsize(src)
    # else:
    # size_of_file(path)
    # if os.path.isfile(r"%s"%src):
    # res = os.path.getsize(src)
    # else:
    # size_of_file(src)
    # print(res)



    # 2、明天上午日考:随机验证码、模拟下载以及打印进度条、文件copy脚本
    #随机验证码
    #
    # import random
    #
    # def make_code(size=4):
    # res = ''
    # for i in range(size):
    # s1 = chr(random.randint(65,90))
    # s2 = str(random.randint(0,9))
    # res += random.choice([s1,s2])
    # return res
    # print(make_code(6))

    # import time
    # def progress(percent):
    # if percent > 1:
    # percent = 1
    # res = int(50 * percent) * "#"
    # print(' [%-50s] %d%%' % (res, int(100 * percent)), end='')
    #
    # recv_size=0
    # total_size=1025011
    #
    # while recv_size < total_size:
    # time.sleep(0.01) # 下载了1024个字节的数据
    #
    # recv_size+=1024 # recv_size=2048
    #
    # # 打印进度条
    # # print(recv_size)
    # percent = recv_size / total_size # 1024 / 333333
    # progress(percent)


    # import sys
    # import os
    #
    # file_path = sys.argv
    # def copy(src,dst):
    # name = os.path.basename(src)
    # print(name)
    # if os.path.isfile(dst):
    # print("目标路径不是个文件夹")
    # return None
    # dst = os.path.join(dst,name)
    # with open(src,"rb") as f1,
    # open(dst,"wb") as f2:
    # f2.write(f1.read())
    # copy(file_path[1],file_path[2])
  • 相关阅读:
    freeswitch录音功能
    jdk安装
    maven阿里云镜像
    idea安装
    idea新建maven项目
    tomcat安装
    idea新建maven web项目
    idea新建java项目
    webpack使用
    ACE 安装指南及示例
  • 原文地址:https://www.cnblogs.com/acnjanna2019/p/12601579.html
Copyright © 2020-2023  润新知