課程
/后端開發(fā)
/Python
/初識(shí)Python
感覺(jué)可以運(yùn)行成功,但哪里錯(cuò)了?
2018-03-24
源自:初識(shí)Python 8-3
正在回答
字符串不像List可以直接改變?cè)瓋?nèi)容,s[0]應(yīng)該只是提取出單個(gè)字符出來(lái)而沒(méi)有改變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 提問(wèn)者
看下是哪個(gè)小節(jié)?同意 1
舉報(bào)
學(xué)python入門視頻教程,讓你快速入門并能編寫簡(jiǎn)單的Python程序
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購(gòu)課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2018-03-24
字符串不像List可以直接改變?cè)瓋?nèi)容,s[0]應(yīng)該只是提取出單個(gè)字符出來(lái)而沒(méi)有改變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
看下是哪個(gè)小節(jié)?同意 1