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("\n")
18             ds=os.path.getsize(filePath)
19     # print(os.path.getsize(filePath))
20 
21 # start here.
22 genSizeFile("20480k",20*1024*1024)

 

相关文章:

  • 2021-12-06
  • 2022-12-23
  • 2021-09-06
  • 2021-09-04
  • 2021-11-15
  • 2021-11-10
  • 2022-03-01
  • 2021-05-30
猜你喜欢
  • 2022-12-23
  • 2021-11-05
  • 2022-12-23
  • 2021-11-07
  • 2022-01-10
  • 2021-11-18
  • 2022-12-23
相关资源
相似解决方案