码迷,mamicode.com
首页 > 编程语言 > 详细

两段小PYTHON,作啥用的,行内人才懂~~~:(

时间:2015-02-16 14:15:50      阅读:195      评论:0      收藏:0      [点我收藏+]

标签:

哎,作也不是,不作也不是。。。。

下次有更新文件时,直接刷新一次了。

#coding: UTF-8

import sys
reload(sys)
sys.setdefaultencoding( "utf-8" )
#从EXCEL文件中按要求组合动词+名词
import xlrd
xlsfile = r"820.xls"
data = xlrd.open_workbook(xlsfile)
zscy = []
dc = []
mc = []
table = data.sheets()[0]
nrows = table.nrows
for i in range(nrows ):
    if table.row_values(i)[3] == u专属词语 :
        zscy.append(table.row_values(i)[0])
    if table.row_values(i)[3] == u动词 :
        dc.append(table.row_values(i)[0])
    if table.row_values(i)[3] == u名词 :
        mc.append(table.row_values(i)[0])

f = open(test.txt, w)
for i in zscy:
    print >>f,i
f.close()

f = open(test2.txt, w)


for i in dc:
    for j in mc:
        print >>f,i+j

f.close()
#coding: UTF-8

#所有词去重过滤
file = open("lice.csv")
qc = []
while 1:
    line = file.readline()
    if not line:
        break
    if line not in qc:
        qc.append(line)



f = open(test.csv, w)
for i in qc:
    print >>f,i.strip()
f.close()

 

两段小PYTHON,作啥用的,行内人才懂~~~:(

标签:

原文地址:http://www.cnblogs.com/aguncn/p/4294006.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!