課程
/后端開發
/Python
/python進階
。。。。。
2015-10-04
源自:python進階 2-7
正在回答
def cmp_ignore_case(s1, s2):??? if (s1[0].lower()+s1[1:] )> (s2[0].lower()+s2[1:]):??????? return 1??? if (s1[0].lower()+s1[1:] )< (s2[0].lower()+s2[1:]):??????? return -1??? return 0print sorted(['bob', 'about', 'Zoo', 'Credit'], cmp_ignore_case)
------------------------------------------------------------------------------------------------
這樣也可以得出正確結果。
兔子愛叫 提問者
德占仁里 回復 兔子愛叫 提問者
舉報
學習函數式、模塊和面向對象編程,掌握Python高級程序設計
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2015-10-06
def cmp_ignore_case(s1, s2):
??? if (s1[0].lower()+s1[1:] )> (s2[0].lower()+s2[1:]):
??????? return 1
??? if (s1[0].lower()+s1[1:] )< (s2[0].lower()+s2[1:]):
??????? return -1
??? return 0
print sorted(['bob', 'about', 'Zoo', 'Credit'], cmp_ignore_case)
------------------------------------------------------------------------------------------------
這樣也可以得出正確結果。