这是我的代码的一部分工作正常;
#taking time average
average= sum(result.expect[0])/len(t)
averagelist=[]
averagelist.append([num-Delta, average])
print(averagelist)
提供输出;
[[-50, 0.99994894092412567]]
[[-45, 0.9999371327219414]]
[[-40, 0.99992064521708557]]
[[-35, 0.99989662709502258]]
[[-30, 0.99985966374414359]]
[[-25, 0.99979843838324323]]
[[-20, 0.99968609192147129]]
[[-15, 0.99944283644552467]]
[[-10, 0.99874864586107459]]
[[-5, 0.99499296595818931]]
[[0, 0.50250021597634276]]
现在我希望能够创建一个新的列表x = -50,-45,-40等 和新列表y = 0.999 ...,0.999 ...,0.999 ......等 有一个简单的方法吗? (我也试过扩展,因为它反对追加函数,这给了我相同的初始输出,但有一个方括号而不是两个。)
答案 0 :(得分:1)
你可以用这个:
list_x = [i[0] for i in averagelist]
list_y = [i[1] for i in averagelist]