尝试将字符串拆分为数字7,我希望7包含在拆分字符串的第二部分中.
码:
a = 'cats can jump up to 7 times their tail length'
words = a.split("7")
print(words)
Run Code Online (Sandbox Code Playgroud)
输出:
['cats can jump up to ', ' times their tail length']
Run Code Online (Sandbox Code Playgroud)
字符串被拆分但第二部分不包括7.
我想知道如何包含7.
注意:不要删除分隔符而不是Python split()的副本,因为分隔符必须是第二个字符串的一部分.
import java.util.*;
public class Map {
public static void main(String[] args) {
Map map = new HashMap();
map.put("father", "Rob");
System.out.println(map.get("father"));
}
}
Run Code Online (Sandbox Code Playgroud)