package com.wangcf; /** * 把字符串"3,1,2,4"以","分割拆分为数组,数组元素并按从小到大的顺序排列 * @author fan * */ public class Test{ /** * 冒泡排序 * @param s * @return */ public int[] paixu(int[] s){ for (int i=s.length; i >0; i--) { int tem; for (int j = 0; j &l…
今天使用split分割"."的时候居然失败了,经过百度发现原来要加转义字符才行. 正确的写法: String test="1.2.3"; String[] s1=test.split("\\."); 结果: 如果不加转义就会分割失败,返回一个空的字符串数组. API中是这样写的: public String[] split(String regex) Splits this string around matches of the given r…
a=open('A.txt','r').readlines() n=3 #份数 qty=len(a)//n if len(a)%n==0 else len(a)//n+1 #每一份的行数 for i in range(n): f=open(str(i+1)+'.txt', 'a') f.writelines(a[i*qty:(i+1)*qty]) f.close() 分割txt文件…
java关于split分割字符串,空的字符串不能得到的问题 class T { public static void main(String args[]) { String num[] = new String[11]; String sLine = "101494|360103660318444|2008/06/17|周润英|1292.0|3085.76|2778.28|912.91|106.0|||"; num = sLine.split("\\|");…