Python代码:

str = "123;456;789"
strlist = str.split(";")
strlist = [int("%s" % s) for s in strlist]
print strlist

最佳答案

String str = "123;456;789";
String[] strList = str.split(";");

ArrayList<Integer> intList = new ArrayList<Integer>();
for (String s : strList) {
    intList.add(Integer.parseInt(s));
}

System.out.println(intList);

关于java - 如何用Java编写此Python代码(使用定界符解析一个整数字符串)?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/4756687/

10-10 04:20