Python の startswith 関数で文字列の先頭一致を調べる ― 2020年04月09日 12時41分56秒
#!/usr/local/bin/python
text = "This is a pen."
print( text.startswith( 'This' ) )
print( text.startswith( 'is', 2, 4 ) )
また、オフセットを指定することで、中間地点の検査も出来る。
% ./str_startswith.py
True
True
最近のコメント