我正在写信给网络共享,这是一段代码
while not created:
fileName = ''.join(random.choice(CANDIDATE_CHARS) for x in range(len))
fullPath = os.path.join(base, fileName)
if not os.path.exists(fullPath):
filesize = random.randint(fileSizeLowerLim, fileSizeUpperLim)
logger.info("Creating file %s, with size %d" %(fullPath, filesize))
with open(fullPath, 'wb') as fout:
if filesize > 0:
fout.write(os.urandom(filesize * 1048576))
sizeLimit -= filesize
allFiles.append(fullPath)
created = True
logger.info("Created file %s, now limit is %d" %(fullPath, sizeLimit))
我得到这个错误:
fout.write(os.urandom(filesize * 1048576))
IOError: [Errno 22] Invalid argument
job remoteMachine finished ended with rc = 1
remoteMachine finished and it failed
当我查看文件时,它已生成但没有数据。我在python中有什么遗漏吗?
我正在使用 32 位 python 在 Windows 7 上运行脚本。