0
我想修改一個在for循環中使用一對key:值的腳本。我必須進行更改,以便for循環可以取得3個值,而不僅僅是1個。不知道如何去做。提前致謝。我得到這個錯誤:使用for循環中的一個鍵的多個值
for fileName,readPct,readhPct,writehPct in hpct_file_list.items():
...
ValueError: need more than 2 values to unpack
這裏的是代碼:
hpct_file_list = {'rhpct_50_80_20_tier2': ['80', '50', '0'], 'whpct_50_20_80_tier2': ['20', '0', '50']}
for fileName,readPct,readhPct,writehPct in hpct_file_list.items():
hostRoot.VmExec("cd C:\\Program Files (x86)\\vdbench")
VmCommon.LogMsg('Creating File : %s '%(fileName))
hostRoot.VmExec("echo validate=yes > %s"%(fileName))
hostRoot.VmExec("echo sd=sda, lun=%s, threads=16, hitarea=25m, size=875G >> %s" %(device_name, fileName))
hostRoot.VmExec("echo wd=wd1, sd=sda, xfersize=512, rdpct=%s, rhpct=%s, whpct=%s, seekpct=random >> %s" % (readPct, readhPct, writehPct, fileName))
hostRoot.VmExec("echo wd=wd2, sd=sda, xfersize=1k, rdpct=%s, rhpct=%s, whpct=%s, seekpct=random >> %s" % (readPct, readhPct, writehPct, fileName))