''.startswith() and ''.endswith() instead of string slicing to check for prefixes or suffixes.

w

 

http://legacy.python.org/dev/peps/pep-0008/

 

Yes: if foo.startswith('bar'):
No:  if foo[:3] == 'bar':

 

posted @ 2017-06-08 18:29  papering  阅读(151)  评论(0编辑  收藏  举报