x = y = 0 #sorts the data into spin up or spin down, then in required eV range
for x in range(0,len(BSlist)):
if 'Spin.Up' in BSlist[x]:
for y in range (x+1,x+(Count)):
if (float(BSlist[y].split()[1]) >= -2.0) and (float(BSlist[y].split()[1]) <= 2.0):
UpList1.extend(BSlist[x:(x+(Count))])
x = ((x // Count) * (Count)) + Count
continue
if 'Spin.Down' in BSlist[x]:
for y in range (x+1,x+(Count)):
if (float(BSlist[y].split()[1]) >= -2.0) and (float(BSlist[y].split()[1]) <= 2.0):
DnList1.extend(BSlist[x:(x+(Count))])
x = ((x // Count) * (Count)) + Count
continue
UpList2 = []#changing to csv form
x = y = 0
for x in range(0,Count):
UpList2.append(str(x))
if x != 0:
y = x
UpList2[x] = UpList2[x] + '\t' + UpList1[x].split()[0] + '\t' +
UpList1[x].split()[1]
while y in range(0,len(UpList1)):
UpList2[x] = UpList2[x] + '\t' + UpList1[y].split()[1]
y = y + Count
if 'Spin.Up' in UpList1[x]:
while y in range(0,len(UpList1)):
UpList2[x] = UpList2[x] + '\t' + UpList1[y][UpList1[y].find('Band'):
(UpList1[y].find('Band')+9)]
y = y + Count
程序的这一部分以预先存储在一个列表中,并对其进行排序成两个单独的列表60个的数据点不排序基于设定的范围的值。之后,它应该通过列表中的每个数据点并检查它们是否在大于或等于-2.0且小于或等于2.0的范围内。但是,它只输出介于-2.0和8.0之间的数据。我们想知道这是否是语法问题,因为它似乎忽略了小于或等于2.0的第二条语句。蟒3.5使用布尔运算符
能告诉你数据的样本(BSlist'的'内容)? –
https://i.stack.imgur.com/LSA1f.png 下面是一张图片的链接,该图片显示了不应打印到列表中的数据示例。如果你看右侧,你会发现没有一个值低于2.000 ...我们试图排除这些数据,但它包含在输出中。 – rprog
所以,基本上,'BSlist'是一个字符串列表,每个字符串都包含两个浮点数,并且只有这些数字中的第二个是感兴趣的,对吗? –