課程
/后端開發
/Python
/初識Python
請定義一個 greet() 函數,它包含一個默認參數,如果沒有傳入,打印 'Hello, world.',如果傳入,打印 'Hello, xxx.'
默認參數是world
2019-12-24
源自:初識Python 7-6
正在回答
這個是Python2.x版本,超不爽,調試好幾次。
#Python?2.x def?greet(g='world'):???? ????print?'hello,{}.'.format(g) greet() greet('Bart') #Python?3.x def?greet(g='world'):???? ????print(f'hello,{g}.') greet() greet('Bart')
def?greet(name?=?'world'): ????print?'Hello,'?+?name?+?'.' greet() greet('import')
舉報
學python入門視頻教程,讓你快速入門并能編寫簡單的Python程序
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2020-01-31
這個是Python2.x版本,超不爽,調試好幾次。
2019-12-25