''.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':

原文地址:https://www.cnblogs.com/rsapaper/p/6964274.html