課程
/后端開發(fā)
/Python
/初識Python
感覺可以運行成功,但哪里錯了?
2018-03-24
源自:初識Python 8-3
正在回答
字符串不像List可以直接改變原內(nèi)容,s[0]應(yīng)該只是提取出單個字符出來而沒有改變s的功能
def firstCharUpper(s):
? ? s=s[:1].upper()+s[1:]
? ? return s
print firstCharUpper('hello')
print firstCharUpper('sunday')
print firstCharUpper('september')
參考:https://www.cnblogs.com/huangbiquan/p/7783057.html
MKSS 提問者
看下是哪個小節(jié)?同意 1
舉報
學(xué)python入門視頻教程,讓你快速入門并能編寫簡單的Python程序
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號
2018-03-24
字符串不像List可以直接改變原內(nèi)容,s[0]應(yīng)該只是提取出單個字符出來而沒有改變s的功能
def firstCharUpper(s):
? ? s=s[:1].upper()+s[1:]
? ? return s
print firstCharUpper('hello')
print firstCharUpper('sunday')
print firstCharUpper('september')
參考:https://www.cnblogs.com/huangbiquan/p/7783057.html
2022-03-23
看下是哪個小節(jié)?同意 1