課程
/后端開發
/Python
/初識Python
s = set(['Adam', 'Lisa', 'Bart', 'Paul'])
Adam==adam
Bart==bart
print 'adam' in s
print 'bart' in s
2016-06-13
源自:初識Python 6-7
正在回答
Bart==bart是變量判斷相等。字符串要加引號
慕后端7303097 提問者
應為這個是set
python 中字符串不可以這樣比較 用的是cmp()方法
例: print cmp('bart','Bart') #輸出結果為0? 即False
????????print cmp('bart','bart')????#輸出結果為1 即True
weibo_喵喵喵喵喵到底有多少_03593603
舉報
學python入門視頻教程,讓你快速入門并能編寫簡單的Python程序
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2016-06-13
Bart==bart是變量判斷相等。字符串要加引號
2016-06-13
應為這個是set
2016-06-13
python 中字符串不可以這樣比較 用的是cmp()方法
例: print cmp('bart','Bart') #輸出結果為0? 即False
????????print cmp('bart','bart')????#輸出結果為1 即True