比较字典中的多个值并获得更大的值键
Compare multiple value in a dictionary and get bigger value key
我如何比较这 2 个键值的最大长度?
我想找到长度更大的最高键名。
{
'UFTBUSD': ['Hammer', 'Belthold', 'Doji', 'Three Outside', 'Hanging Man', 'Closing Marubozu', 'Dragonfly Doji', 'Engulfing Pattern', 'Gravestone Doji', 'Harami Pattern'],
'ANCBUSD': ['Belthold', 'Doji', 'Three Outside', 'Shooting Star', 'Closing Marubozu', 'Engulfing Pattern', 'Harami Pattern']
}
thisdict = {
'UFTBUSD': ['Hammer', 'Belthold', 'Doji', 'Three Outside', 'Hanging Man', 'Closing Marubozu', 'Dragonfly Doji', 'Engulfing Pattern', 'Gravestone Doji', 'Harami Pattern'],
'ANCBUSD': ['Belthold', 'Doji', 'Three Outside', 'Shooting Star', 'Closing Marubozu', 'Engulfing Pattern', 'Harami Pattern']
}
def find_longest_key(mydict):
count_value = 0
for x, y in mydict.items():
for value in y:
if len(value) > count_value:
count_value = len(value)
print(len(value))
longest_value = value
longest_values_key = x
print(longest_value)
print(longest_values_key)
return longest_values_key
find_longest_key(thisdict)
thisdict = {
'UFTBUSD': ['Hammer', 'Belthold', 'Doji', 'Three Outside', 'Hanging Man', 'Closing Marubozu', 'Dragonfly Doji', 'Engulfing Pattern', 'Gravestone Doji', 'Harami Pattern'],
'ANCBUSD': ['Belthold', 'Doji', 'Three Outside', 'Shooting Star', 'Closing Marubozu', 'Engulfing Pattern', 'Harami Pattern']
}
def find_largest_key(pattern_with_symbol):
count = 0
for key, value in pattern_with_symbol.items():
if len(value) > count:
count = len(value)
long_key = key
return long_key
print(find_largest_key(this_dict))
我如何比较这 2 个键值的最大长度? 我想找到长度更大的最高键名。
{
'UFTBUSD': ['Hammer', 'Belthold', 'Doji', 'Three Outside', 'Hanging Man', 'Closing Marubozu', 'Dragonfly Doji', 'Engulfing Pattern', 'Gravestone Doji', 'Harami Pattern'],
'ANCBUSD': ['Belthold', 'Doji', 'Three Outside', 'Shooting Star', 'Closing Marubozu', 'Engulfing Pattern', 'Harami Pattern']
}
thisdict = {
'UFTBUSD': ['Hammer', 'Belthold', 'Doji', 'Three Outside', 'Hanging Man', 'Closing Marubozu', 'Dragonfly Doji', 'Engulfing Pattern', 'Gravestone Doji', 'Harami Pattern'],
'ANCBUSD': ['Belthold', 'Doji', 'Three Outside', 'Shooting Star', 'Closing Marubozu', 'Engulfing Pattern', 'Harami Pattern']
}
def find_longest_key(mydict):
count_value = 0
for x, y in mydict.items():
for value in y:
if len(value) > count_value:
count_value = len(value)
print(len(value))
longest_value = value
longest_values_key = x
print(longest_value)
print(longest_values_key)
return longest_values_key
find_longest_key(thisdict)
thisdict = {
'UFTBUSD': ['Hammer', 'Belthold', 'Doji', 'Three Outside', 'Hanging Man', 'Closing Marubozu', 'Dragonfly Doji', 'Engulfing Pattern', 'Gravestone Doji', 'Harami Pattern'],
'ANCBUSD': ['Belthold', 'Doji', 'Three Outside', 'Shooting Star', 'Closing Marubozu', 'Engulfing Pattern', 'Harami Pattern']
}
def find_largest_key(pattern_with_symbol):
count = 0
for key, value in pattern_with_symbol.items():
if len(value) > count:
count = len(value)
long_key = key
return long_key
print(find_largest_key(this_dict))