Quickly create large file on a Windows system

前端 未结 23 2396
别那么骄傲
别那么骄傲 2020-12-07 06:35

In the same vein as Quickly create a large file on a Linux system, I\'d like to quickly create a large file on a Windows system. By large I\'m thinking 5 GB.

23条回答
  •  醉话见心
    2020-12-07 07:10

    Short of writing a full application, us Python guys can achieve files of any size with four lines, same snippet on Windows and Linux (the os.stat() line is just a check):

    >>> f = open('myfile.txt','w')
    >>> f.seek(1024-1) # an example, pick any size
    >>> f.write('\x00')
    >>> f.close()
    >>> os.stat('myfile.txt').st_size
    1024L
    >>>
    

提交回复
热议问题