python-元组比较

我有一本这样定义的字典:

d = {"date": tuple(date),"open":tuple(open),"close":tuple(close),"min":tuple(min),"max":tuple(max),"MA":tuple(ma)}

这些元组中的每个元组都包含一个值列表(每个元组具有相同数量的值),如果“ close”优于“ MA”,我该如何迭代专用键的每个值以进行比较?

解决方法:

我想念什么? d [‘close’]> d [ ‘MA’]?

编辑:回复,您的评论

[…] what I want to return is how many times one element of “close” is > to the matching element of MA . (same tuple index)

sum( pair[0] > pair[1] for pair in zip(d['close'], d['MA']) )
上一篇:c-模板参数constexpr的显式指定参数无效


下一篇:java-Oracle无效标识符不理解字符串