課程
/后端開發
/Python
/初識Python
a = 'python'?
print 'hello,' ? ?, a not 'world'?
?b = ' ?'?
print 'hello,' ? ? , b not 'world'?
?為什么無法輸出?!
2017-07-21
源自:初識Python 3-9
正在回答
not是python中的關鍵字,第三句b前面多了一個縮進。
yansima 提問者
print 'hello,', not 'world'?
b =''?
print 'hello,', not 'world'
--------------------------------------------------------
a not 'world' 和b not 'world' 沒有意義,not...運算出來應該是布爾值,這玩意兒不能用人類的思維來(非運算not前面沒東西)。
a與not'world'之間不存在邏輯運算
現在我不知道你想表達什么,你可以根據需要這么寫
print ('hello,' , a, not 'world')
b = ' ?'?
print ('hello,' , b, not 'world')
或者這么寫
print 'hello,' ? ?, a or not 'world'?
print 'hello,' ? ? , b or not 'world'?
應該
print ('hello,' , a, 'not world')
print ('hello,' , b, 'not world')
舉報
學python入門視頻教程,讓你快速入門并能編寫簡單的Python程序
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2017-07-21
not是python中的關鍵字,第三句b前面多了一個縮進。
2017-07-25
a = 'python'?
print 'hello,', not 'world'?
b =''?
print 'hello,', not 'world'
--------------------------------------------------------
a not 'world' 和b not 'world' 沒有意義,not...運算出來應該是布爾值,這玩意兒不能用人類的思維來(非運算not前面沒東西)。
2017-07-21
a與not'world'之間不存在邏輯運算
現在我不知道你想表達什么,你可以根據需要這么寫
a = 'python'?
print ('hello,' , a, not 'world')
b = ' ?'?
print ('hello,' , b, not 'world')
或者這么寫
a = 'python'?
print 'hello,' ? ?, a or not 'world'?
b = ' ?'?
print 'hello,' ? ? , b or not 'world'?
2017-07-21
應該
a = 'python'?
print ('hello,' , a, 'not world')
b = ' ?'?
print ('hello,' , b, 'not world')