2013-05-03 127 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

回答

相關問題