import xlwt import os def write_excel(words,filename): #写入Excel的函数,words是数据,filename是文件名 wb=xlwt.Workbook() sheet=wb.add_sheet('sheet1') attr=['词语','词性','词频'] #第一行:属性行 for col in range(3): sheet.write(0,col,attr[col]) for row in range(1,len(words)+1)
1.使用for循环 for line in `cat filename` do echo $line done 2.使用for循环 for line in $(cat filename) do echo $line done 3.使用while循环 while read -r line do echo $line done < filename
#!/bin/shcd 'home/usrname/'ls cd '/home/usrname/VOC2007/Annotations/' for file in `ls /home/usrname/VOC2007/Annotations/`do echo $file sed -i '/<?xml version="1.0" ?>/d' $filedone echo 'all is ok.'