python startswith() 函数时间:2023-03-10 00:03:07 startswith() 作用:判断字符串是否以指定字符或子字符串开头 >>> s = "my name is ming" >>> >>> s.startswith('m') True >>> s.startswith('b') False >>> 常用环境:用于if判断 >>> if s.startswith('hel'): print ("you are right") else: print ("you are wrang") # 执行结果 you are right