这是我的代码:
if condition == '1':
a = glob.glob("DDtest/targetimagelist1/*")
b = glob.glob("DDtest/distractorimagelist1/*")
c = glob.glob("DDtest/targetimagelist2/*")
d = glob.glob("DDtest/distractorimagelist3/*")
e = glob.glob("DDtest/targetimagelist4/*")
elif condition == '2':
a = glob.glob("DDtest/targetimagelist1/*")
b = glob.glob("DDtest/distractorimagelist1/*")
c = glob.glob("DDtest/targetimagelist2/*")
e = glob.glob("DDtest/distractorimagelist3/*")
d = glob.glob("DDtest/targetimagelist4/*")
elif condition == '3':
a = glob.glob("DDtest/targetimagelist1/*")
b = glob.glob("DDtest/distractorimagelist1/*")
e = glob.glob("DDtest/targetimagelist2/*")
d = glob.glob("DDtest/distractorimagelist3/*")
c = glob.glob("DDtest/targetimagelist4/*")
elif condition == '4':
a = glob.glob("DDtest/targetimagelist1/*")
b = glob.glob("DDtest/distractorimagelist1/*")
e = glob.glob("DDtest/targetimagelist2/*")
c = glob.glob("DDtest/distractorimagelist3/*")
d = glob.glob("DDtest/targetimagelist4/*")
elif condition == '5':
a = glob.glob("DDtest/targetimagelist1/*")
b = glob.glob("DDtest/distractorimagelist1/*")
d = glob.glob("DDtest/targetimagelist2/*")
c = glob.glob("DDtest/distractorimagelist3/*")
e = glob.glob("DDtest/targetimagelist4/*")
elif condition == '6':
a = glob.glob("DDtest/targetimagelist1/*")
b = glob.glob("DDtest/distractorimagelist1/*")
d = glob.glob("DDtest/targetimagelist2/*")
e = glob.glob("DDtest/distractorimagelist3/*")
c = glob.glob("DDtest/targetimagelist4/*")
elif condition == '7':
d = glob.glob("DDtest/targetimagelist1/*")
b = glob.glob("DDtest/distractorimagelist2/*")
a = glob.glob("DDtest/targetimagelist2/*")
c = glob.glob("DDtest/distractorimagelist3/*")
e = glob.glob("DDtest/targetimagelist4/*")
elif condition == '8':
d = glob.glob("DDtest/targetimagelist1/*")
b = glob.glob("DDtest/distractorimagelist2/*")
a = glob.glob("DDtest/targetimagelist2/*")
e = glob.glob("DDtest/distractorimagelist3/*")
c = glob.glob("DDtest/targetimagelist4/*")
elif condition == '9':
d = glob.glob("DDtest/targetimagelist1/*")
b = glob.glob("DDtest/distractorimagelist3/*")
e = glob.glob("DDtest/targetimagelist2/*")
a = glob.glob("DDtest/distractorimagelist3/*")
c = glob.glob("DDtest/targetimagelist4/*")
elif condition == '10':
d = glob.glob("DDtest/targetimagelist1/*")
b = glob.glob("DDtest/distractorimagelist4/*")
e = glob.glob("DDtest/targetimagelist2/*")
c = glob.glob("DDtest/distractorimagelist3/*")
a = glob.glob("DDtest/targetimagelist4/*")
elif condition == '11':
d = glob.glob("DDtest/targetimagelist1/*")
b = glob.glob("DDtest/distractorimagelist4/*")
c = glob.glob("DDtest/targetimagelist2/*")
e = glob.glob("DDtest/distractorimagelist3/*")
a = glob.glob("DDtest/targetimagelist4/*")
elif condition == '12':
d = glob.glob("DDtest/targetimagelist1/*")
b = glob.glob("DDtest/distractorimagelist3/*")
c = glob.glob("DDtest/targetimagelist2/*")
a = glob.glob("DDtest/distractorimagelist3/*")
e = glob.glob("DDtest/targetimagelist4/*")
elif condition == '13':
c = glob.glob("DDtest/targetimagelist1/*")
b = glob.glob("DDtest/distractorimagelist2/*")
a = glob.glob("DDtest/targetimagelist2/*")
d = glob.glob("DDtest/distractorimagelist3/*")
e = glob.glob("DDtest/targetimagelist4/*")
elif condition == '14':
c = glob.glob("DDtest/targetimagelist1/*")
b = glob.glob("DDtest/distractorimagelist2/*")
a = glob.glob("DDtest/targetimagelist2/*")
e = glob.glob("DDtest/distractorimagelist3/*")
d = glob.glob("DDtest/targetimagelist4/*")
elif condition == '15':
c = glob.glob("DDtest/targetimagelist1/*")
b = glob.glob("DDtest/distractorimagelist3/*")
e = glob.glob("DDtest/targetimagelist2/*")
a = glob.glob("DDtest/distractorimagelist3/*")
d = glob.glob("DDtest/targetimagelist4/*")
elif condition == '16':
c = glob.glob("DDtest/targetimagelist1/*")
b = glob.glob("DDtest/distractorimagelist4/*")
e = glob.glob("DDtest/targetimagelist2/*")
d = glob.glob("DDtest/distractorimagelist3/*")
a = glob.glob("DDtest/targetimagelist4/*")
elif condition == '17':
c = glob.glob("DDtest/targetimagelist1/*")
b = glob.glob("DDtest/distractorimagelist4/*")
d = glob.glob("DDtest/targetimagelist2/*")
e = glob.glob("DDtest/distractorimagelist3/*")
a = glob.glob("DDtest/targetimagelist4/*")
elif condition == '18':
c = glob.glob("DDtest/targetimagelist1/*")
b = glob.glob("DDtest/distractorimagelist3/*")
d = glob.glob("DDtest/targetimagelist2/*")
a = glob.glob("DDtest/distractorimagelist3/*")
e = glob.glob("DDtest/targetimagelist4/*")
elif condition == '19':
e = glob.glob("DDtest/targetimagelist1/*")
b = glob.glob("DDtest/distractorimagelist2/*")
a = glob.glob("DDtest/targetimagelist2/*")
c = glob.glob("DDtest/distractorimagelist3/*")
d = glob.glob("DDtest/targetimagelist4/*")
elif condition == '20':
e = glob.glob("DDtest/targetimagelist1/*")
b = glob.glob("DDtest/distractorimagelist2/*")
a = glob.glob("DDtest/targetimagelist2/*")
d = glob.glob("DDtest/distractorimagelist3/*")
c = glob.glob("DDtest/targetimagelist4/*")
elif condition == '21':
e = glob.glob("DDtest/targetimagelist1/*")
b = glob.glob("DDtest/distractorimagelist3/*")
c = glob.glob("DDtest/targetimagelist2/*")
a = glob.glob("DDtest/distractorimagelist3/*")
d = glob.glob("DDtest/targetimagelist4/*")
elif condition == '22':
e = glob.glob("DDtest/targetimagelist1/*")
b = glob.glob("DDtest/distractorimagelist4/*")
c = glob.glob("DDtest/targetimagelist2/*")
d = glob.glob("DDtest/distractorimagelist3/*")
a = glob.glob("DDtest/targetimagelist4/*")
elif condition == '23':
e = glob.glob("DDtest/targetimagelist1/*")
b = glob.glob("DDtest/distractorimagelist4/*")
d = glob.glob("DDtest/targetimagelist2/*")
c = glob.glob("DDtest/distractorimagelist3/*")
a = glob.glob("DDtest/targetimagelist4/*")
elif condition == '24':
e = glob.glob("DDtest/targetimagelist1/*")
b = glob.glob("DDtest/distractorimagelist3/*")
d = glob.glob("DDtest/targetimagelist2/*")
a = glob.glob("DDtest/distractorimagelist3/*")
c = glob.glob("DDtest/targetimagelist4/*")
基本上,它的作用是根据 a、c、d、e 的所有组合从不同的列表中提取,并使 a 和 b 对应。这段代码工作正常,但不是很漂亮。我想知道是否有人对我用更少的代码行做同样的事情有任何建议。最重要的是,我只是想扩展我编写代码的知识,所以如果你知道有一种更雄辩的方式来写这个,请告诉我。:)