2013-05-03 99 views
0

我写网络共享,这是一段代码,写IO错误:[错误22]无效参数的Python写

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上运行脚本。

+1

您使用的是什么操作系统? – Blender 2013-05-03 19:50:15

回答

相关问题