python保留两位小数: In [1]: a = 5.026 In [2]: b = 5.000 In [3]: round(a,2) Out[3]: 5.03 In [4]: round(b,2) Out[4]: 5.0 In [5]: '%.2f' % a Out[5]: '5.03' In [6]: '%.2f' % b Out[6]: '5.00' In [7]: float('%.2f' % a) Out[7]: 5.03 In [8]: float('%.2f' % b) Out[
参数: dict1, dict2 需求:如果dict1和dict2中有不同的key,那么返回这个(key, dict1[key]):如果dict1和dict2中有相同的key,但是value不同,返回这个(key, dict1[key]) 实现: def dict_different_data(first, second): """ get the different data bewtten two dicts objects return :result = first