zoukankan      html  css  js  c++  java
  • 生成指定大小的文件

     1 #!/usr/bin/env python
     2 # -*- coding: utf-8 -*-
     3 
     4 import os
     5 import random
     6 
     7 def genSizeFile(fileName, fileSize):
     8     #file path
     9     filePath="Data"+fileName+".txt"
    10 
    11     # 生成固定大小的文件
    12     # date size
    13     ds=0
    14     with open(filePath, "w") as f:
    15         while ds<fileSize:
    16             f.write(str(round(random.uniform(-1000, 1000),2)))
    17             f.write("
    ")
    18             ds=os.path.getsize(filePath)
    19     # print(os.path.getsize(filePath))
    20 
    21 # start here.
    22 genSizeFile("20480k",20*1024*1024)
  • 相关阅读:
    BZOJ3156 防御准备
    BZOJ1911 [APIO2010] 特别行动队
    BZOJ1096 [ZJOI2007] 仓库建设
    HDU
    斜率优化的各种板子
    HDU
    HDU
    HDU
    HDU
    HDU
  • 原文地址:https://www.cnblogs.com/xiaoyaowuming/p/6264263.html
Copyright © 2011-2022 走看看