In [20]: 'my name is insane'.startswith('my')
out [20]: True
In [21]: 'my name is insane'.endswith('my')
out [21]: False
实战
# coding:utf-8
info ='this is a string example!'
result = info.startswith('this')print(result)
result = info.startswith('this is a string example!')print(result)print(bool(info =='this is a string example!'))
result = info.endswith('!')print(result)
result = info.endswith('a')print('result:', result)
result = info.endswith('this is a string example!')print(result)
True
True
True
True
result: False
True
Process finished with exit code 0