判断是否以什么结尾
filename = "config.properties"
if filename.endswith(".properties"):
print("字符串以 .properties 结尾")
else:
print("字符串不以 .properties 结尾")
判断是否以什么开头
string = "base64encode"
if string.startswith("base"):
print("字符串以 'base' 开头")
else:
print("字符串不以 'base' 开头")
判断是否包含有
string = "hello_world"
if "_" in string:
print("字符串中包含下划线")
else:
print("字符串中不包含下划线")