📜  python 字符串以列表的任何字符开头 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:02.694000             🧑  作者: Mango

代码示例1
# `str.startswith` supports checking for multiple prefixes:
>>> "abcde".startswith(("xyz", "abc"))
True
# You must use a tuple though, so convert your lists using tuple()
>>> prefixes = ["xyz", "abc"]
>>> "abcde".startswith(tuple(prefixes))
True