介紹字串物件:str.swapcase()
官方文件的介紹:
Return a copy of the string with uppercase characters converted to lowercase and vice versa. Note that it is not necessarily true that s.swapcase().swapcase() == s.
簡單來說swapcase()
這個方法可以改變字母的大小寫
- 語法:
範例:str.swapcase();
#全部變大寫 text = 'we are learning python'.swapcase 'WR ARE LEARNING PYTHON' #原本大寫的變小寫,小寫的字母變大寫 text = 'We Are Learning Python'.swapcase 'wE aRA lEARNING pYTHON
- 程式設計實作題作業網址
程式設計實作題