在下面的方法定义,什么是*和**为做param2?
def foo(param1, *param2):
def bar(param1, **param2):
Run Code Online (Sandbox Code Playgroud) python syntax parameter-passing variadic-functions argument-unpacking
Python已经string.find()并且string.rfind()在字符串中获取子字符串的索引.
我想知道,也许有类似的东西string.find_all()可以返回所有已创建的索引(不仅从开始或从头到尾)?
例如:
string = "test test test test"
print string.find('test') # 0
print string.rfind('test') # 15
#this is the goal
print string.find_all('test') # [0,5,10,15]
Run Code Online (Sandbox Code Playgroud)