直接修改不行嗎,新手。。。
def firstCharUpper(s):
? ? ?s[:1].upper()
? ? ?return s
print firstCharUpper('hello')
print firstCharUpper('sunday')
print firstCharUpper('september')
def firstCharUpper(s):
? ? ?s[:1].upper()
? ? ?return s
print firstCharUpper('hello')
print firstCharUpper('sunday')
print firstCharUpper('september')
2018-07-04
舉報
2018-11-14
def firstCharUpper(s):
? ? return s.upper()[:1] + s[1:]? #先把所有的小寫變成大寫,把首字母切出來,然后連接其他小寫字母
def firstCharUpper(s):
? ? return s[0].upper() + s[1:]? ?#只把首字母(索引是s[0])打印出來,然后連接其他小寫字母
以上兩種寫法都是需要把首字母跟生下來的小寫字母連接的
2018-07-16
用 .title()
2018-07-12
樓上說的很好,最后代碼有一點小問題,應該是:s[0].upper() + s[1:]
2018-07-04
題目意思是要把首字母大寫,其他的還是小寫哦,你寫的代碼運行出來是除了首字母是小寫,從第二位開始全部大寫