zoukankan      html  css  js  c++  java
  • 20.03.30作业

    import sys
    import time
    import os

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

    path = sys.argv[1]

    sum = 0
    for line in os.listdir(path):
        path2 = os.path.join(path, line)
        if os.path.isfile(path2):  # 判断这个文件是否存在
           sum += os.path.getsize(path2)
        elif os.path.isdir(path2): # 判断这个目录是否存在
           sum += os.path.getsize(path2)
        else:
            continue
    print(sum)

    文件拷贝脚本

    src_file =sys.argv[1]
    dst_file =sys.argv[2]
    with open(src_file,'r',encoding='utf-8')as r_f,
        open(dst_file,'w',encoding='utf-8')as w_f:
        w_f.write(r_f.read())

    随机验证码

    import random


    def make_code(size=4):
        res = ''
        for in range(size):
            s1 = chr(random.randint(65, 90))
            s2 = str(random.randint(0, 9))
            res += random.choice([s1, s2])
        return res

    模拟下载

    recv_size = 0
    total_size = 1025011

    while recv_size total_size:
        time.sleep(0.01)  # 0.01秒下载了1024个字节的数据

        recv_size += 1024  # recv_size=2048
        print(recv_size)

    进度条打印

    def progress(percent):
        if percent 1:
            percent = 1
        res = int(50 percent) '#'
        print()
  • 相关阅读:
    Windbg 基本调试常识(转)
    善用VS中的Code Snippet来提高开发效率
    如何跟踪调试Software product?
    Visual Studio 2008 每日提示(二十七)
    6步确保 windbg 成功调试 .net(转)
    Visual Studio 2005 重置设置
    Print to Output /To trace runtime
    Windbg安装和配置(转)
    C++与C#交互
    All hands on deck
  • 原文地址:https://www.cnblogs.com/zhangjinyi97/p/12601759.html
Copyright © 2011-2022 走看看