给定以下字符串:
foo = "hello + there"
bar = "hello - there"
baz = "one + two - three"
fuz = "one - two + three"
是否有(相对)直接的方法来获取第一个字符的索引,即+
或-
foo.index_multiple('+-') # 6
bar.index_multiple('+-') # 6
baz.index_multiple('+-') # 4
fuz.index_multiple('+-') # 4
编辑:我不要求定制代码(例如Python例程)——这相对简单,我可以自己做。我只想知道是否有内置的用于此目的的东西,可以使用正则表达式,也可以不使用正则表达式
可以通过以下方式使用^{} :
相关问题 更多 >
编程相关推荐