概要
str.title()
str:文字列- 単語毎に、頭文字のみ大文字にする
- 組込み型 文字列メソッド
実行結果
print('abc DEF GhI jKL'.title())
表示イメージ
Abc Def Ghi Jkl
str.startswith(prefix[, start[, end]])
str:検索される文字列print("1234567123456712345671234567".startswith("123")) print("1234567123456712345671234567".startswith("567")) print("1234567123456712345671234567".startswith("456",3)) print("1234567123456712345671234567".startswith("712",6,20)) print("1234567123456712345671234567".startswith("345",6,10))
True False True True False
str.splitlines(keepends=False)
str:改行を含んだ文字列print('11 1\n\n22 22\r33\r\n'.splitlines()) print('11 1\n\n22 22\r33\r\n'.splitlines(keepends=True)) ward='''11111 22 33 333 4 5 5 5 ''' print(ward.splitlines()) print(ward.splitlines(keepends=True))
['11 1', '', '22 22', '33'] ['11 1\n', '\n', '22 22\r', '33\r\n'] ['11111', '22', '', '33 333', '4', '5 5 5'] ['11111\n', '22\n', '\n', '33 333\n', '4\n', '5 5 5\n']
str.split(sep=None, maxsplit=- 1)
str:区切り文字を含んだ文字列print("123,45,678,9".split(",")) print("123,45,678,9".split(",",2)) print("123,45,678,9".split(",",maxsplit=2)) print("123,45,678,9".split(" "))
['123', '45', '678', '9'] ['123', '45', '678,9'] ['123', '45', '678,9'] ['123,45,678,9']