1.2.3.41.2.5.62.410.6变成1.234,1.256,2.4,10.6 def get_bom_namenum(self, cr, uid, ids, field_name, arg, context=None): rvalue={} for obj in self.browse(cr,uid,ids,context=None): firstnum=‘‘ centernum=‘‘ endnum=0.0 for i in range(len(obj.name.split(‘.‘))): if i==0: firstnum=obj.name.split(‘.‘)[0]+‘.‘ else: centernum+=obj.name.split(‘.‘)[i] endnum=firstnum+centernum rvalue[obj.id]=float(endnum) return rvalue
list1=[1.22222,2.3333,3.2222,3.14145,2.025] sorted(list1) print sorted(list1) [1.22222, 2.025, 2.3333, 3.14145, 3.2222]
原文地址:https://www.cnblogs.com/1314520xh/p/8821422.html
时间: 2024-10-10 02:24:40