pythonにおける文字列処理関数

747 ワード

検索
title_str="   This is a sentence. This is other sentence   "
print(title_str.find('This',10,20))
print(title_str.find('This'))

join接合
dirs='','usr','local','bin'
print('/'.join(dirs))

小文字
name='Grubby'
names= ['grubby','green','lucy']
if name.lower() in names:
    print('found it!')

置換
print('this is a test'.replace('is','rep'))

切り分ける
print('/usr/local/bin'.split('/'))

スペースの削除
print('   with whitespace   '.strip())