本帖最后由 ubuntu_mark 于 2011-07-13 14:36 编辑 des1与des2都是从数据库读出来的,为什么做了split('\n')处理,结果确不一样,处理后des2的结尾有'\r',des1确没, 但我需要‘\r’以方便后面的处理,这是为什么呢 des1=''' name:Country News url:http://www.countrynews.com.au/ type:NEWS''' des1.split('\n') [u'name:Country News', u'url:http://www.countrynews.com.au/', u'type:NEWS'] des2=''' name:篱笆论坛 Fo...
by ubuntu_mark - Python - 2011-08-01 17:14:33 阅读(9633) 回复(8)
[color="#00c600"]>>> [color="#808000"]help [color="#000000"]([color="#808000"]str[color="#00c600"].[color="#808000"]split[color="#000000"]) Help on method_descriptor: split(...) S.split([sep [,maxsplit]]) -> list of strings Return a list of the words in the string S, using sep as the delimiter string. If maxsplit is given, at most maxsplit splits are done. If sep is n...
Inter_B.txt的内容:
1|FFFFFFFFFFFFFFFF
2|FFFFFFFFFFFFFFFF
$i_B="Inter_B.txt";
open(FH3, "<$i_B");
while(
1 213 2.2 123433, 123432, 235879,225558, 上面一行从文件读进来的时候,怎么用split把这些元素读成一个矩阵的元素,后面几个元素多了个逗号,不想要这个逗号, 上面的分割符号都是tab,结果想作为@array,有7个元素。split大致怎么写!实现不了的话,一般的正则怎么实现 谢谢,后面的几个元素都是6位整数。
split 能否按照如下规则分割文件: 将文件: A: dfsdf skfdjksd B: dskdjf dkfj C: dsjfkd sjdfk 如何使用命令将文件分成3个文件 A B C 并且文件名是A,B,C
请问在shell中如何split字符串 在网上找了两种方法都不行,请给你例子,最后解释一下为什么这两个例子不对 方法1: 3.str="hello,world,i,like,you,babalala" 4.arr=(${str//,/ }) 5. 6.for i in ${arr[@]} 7.do 8. echo $i 9.done ===== 方法2: name="76868&5676&435&43526&334&12312312&12321" awk 'BEGIN {print split('"\"$name\""', filearray, "&")}'
我用mpstat -P ALL |awk '/AM/{printf "%5s %5s %5s\n", $3,$4,$10 }' 输出如下信息 CPU %user %idle all 0.14 98.31 0 0.14 98.36 1 0.14 98.25 我想用split拆分成如下内容要怎么做 CPU %user %idle all 0 98 0 0 98 1 0 98
大家好! 学习java,但简单一个程序遇到问题。非常奇怪! 我的test.txt文件内容如下: text.txt 111111111111 222222222,333333333 333333333333,44444444 55555555 4444444444444 code如下: BufferedReader in =new BufferedReader(new FileReader("test.txt")); String ss1=null; while((ss1=in.readLine())!=null){ System.out.println(ss1.length()); String [] words=ss1.split(",| "); ...