python关于列表中字符串类型数字排序错误问题
文章来源:https://blog.csdn.net/h1394524798/article/details/102636349
把类型转换后,排序正确
d = ['1185878', '1186884', '1187328', '1187829', '1188113', '1189179', '1189492', '452697', '452698', '452699', '452700', '452701', '452702', '452703', '452704', '452705', '452706', '452707', '452708', '452709', '452710', '452711', '452712', '452713', '452714', '452715', '452716', '452717', '452718', '452719', '452720', '452721', '452722', '465068', '475922', '492331', '507197', '528136', '540404', '557527', '567688', '572969', '575986', '581177', '584358', '589701', '592862', '598272', '601266', '606115', '608879', '614994', '617657', '622321', '624609', '629133', '630184', '631794', '636123', '637522', '638788', '643487', '643488', '646073', '650391', '652776', '658147', '660280', '664461', '666934', '671010', '673219', '677370', '679580', '683738', '685970', '690242', '692324', '696240', '698382', '702477', '704089', '708140', '710609', '714237', '716308', '720135', '722141', '725908', '727792', '731584', '733992', '737620', '739629', '743131', '744995', '748311', '750748', '750776', '753582', '754179', '754237', '754517', '754652', '754848', '755308', '756089', '756306', '756448', '756738', '757705', '759458', '759851', '760941', '761563', '762853', '764950', '765543', '767370', '768344', '769171', '771712', '773041', '774435', '777771', '778125', '778928', '782528', '782925', '783699', '784604', '787537', '787981', '788844', '792226', '793118', '794062', '796045', '797071', '797740', '798653', '801000', '801472', '803342', '805790', '806552', '808256', '810485', '811190', '812910', '815657', '816140', '817555', '819910', '820608', '821517', '824630', '825329', '826590', '828975', '829342', '830207', '832957', '833657', '834560', '836145', '838075', '839137', '841125', '842681', '843082', '844764', '846685', '847392', '847975', '851364', '851847', '852968', '854963', '855689', '856869', '859357', '859957', '860970', '863316', '863880', '865109', '867478', '868158', '869047', '871871', '872447', '873060', '876147', '876347', '876989', '879798', '880211', '880612', '883252', '884294', '884973', '887054', '887532', '888574', '890882', '891393', '892515', '893551', '895136', '895491', '896218', '898601', '899154', '901787', '902377', '903499', '905143', '905849', '906636', '908821', '909372', '911193', '912489', '913425', '915334', '916450', '917277', '918705', '919210', '920104', '922234', '922592', '923335', '925564', '926291', '927281', '929343', '929680', '930386', '932312', '932337', '932679', '933553', '935297', '936029', '938391', '939189', '942087', '942382', '942957', '945188', '945477', '946026', '948169', '948407', '949890', '950985', '951404', '952444', '954180', '954720', '957044', '957331', '957903', '960063', '960725', '962919', '964272', '964985', '965708', '966268', '966751', '968787', '969242', '969595', '971484', '971875', '972848', '974461', '974937', '975627', '977227', '978033', '979776', '980202', '980582', '980948', '982842', '983370', '983874', '984053', '985440', '985950', '986588', '988439', '988947', '991212', '991865', '993135', '993470', '994060', '995987', '996345', '997144', '998630', '999562'] for i in range(len(d)): b=int(d[i]) d[i]=b d.sort(reverse=False) print(d)
一切技术都是为业务服务,脱离业务的技术一文不值!