Klang(金浪)AI量化论坛

    • 注册
    • 登录
    • 版块
    • 最新
    • 标签
    • 热门
    • 用户
    • 群组

    Klang zip代码

    Klang使用
    1
    1
    90
    正在加载更多帖子
    • 从旧到新
    • 从新到旧
    • 最多赞同
    回复
    • 在新帖中回复
    登录后回复
    此主题已被删除。只有拥有主题管理权限的用户可以查看。
    • A
      asmcos 管理员 最后由 asmcos 编辑

      import zipfile
      import os,shutil
      
      
      src_dir = os.path.expanduser("xxxx/.klang")
      targetname = 'stockdata.zip'
      print("正在压缩文件")
      
      z = zipfile.ZipFile(targetname, 'w', zipfile.ZIP_DEFLATED)  # 参数一:文件夹名
      for dirpath, dirnames, filenames in os.walk(src_dir):
          fpath = dirpath.replace(src_dir, '')
          fpath = fpath and fpath + os.sep or ''
          for filename in filenames:
              z.write(os.path.join(dirpath, filename), fpath+filename)
              print (fpath+filename)
      z.close()
      
      shutil.move(targetname,os.path.expanduser("xxx/xxx/public/"+targetname))
      
      
      1 条回复 最后回复 回复 引用 0
      • First post
        Last post