#自定义key ${keys} create list key1 key2 key3 #自定义value ${values} create list value1 value2 value3 #在两个input框输入keys 和vlues : FOR ${i} IN RANGE 3 \ input text id=keys ${keys[${i}]} #输入key \ i
基本思路是,将key对应的value设置为list,将对应的值append进去. 示例: f=open("a1.txt") ha={} for i in f: i=i.strip().split() print(i[0],i[1]) for k in i[1:]: ha.setdefault(i[0],[]).append(k) print("#"*10) for k in ha: print(k,sorted(list(set(ha[k])))) 示例文件和输出如