第一期 Python 程式設計入門共學營作業任務五


今天跟大家介紹說明Python 字串物件的一個方法 str.title()

Return a titlecased version of the string where words 
start with an uppercase character and the remaining 
characters are lowercase.

意思是說我們可以透過使用字串str.title()的方法,將字串中每一個字的第一個字母轉成大寫其餘字元為小寫。可見下面程式範例:

strTitle = 'the school have many students.'
# 將輸入每個字第一個字元轉成大寫並印出
# The School Have Many Students.
print(strTitle.title())

程式設計實作
https://repl.it/@kevinlo88/python-basic-hw05

#第一期Python程式設計入門共學營






你可能感興趣的文章

物件屬性描述器 Property Descriptor(一)

物件屬性描述器 Property Descriptor(一)

MTR04_1019

MTR04_1019

SQL-injection lab(5)

SQL-injection lab(5)






留言討論