zoukankan      html  css  js  c++  java
  • python txt、excel读写

    #从txt写入excel
    workbook = xlsxwriter.Workbook('植保网.xlsx') #创建工作簿
    sheet = workbook.add_worksheet()
    r=0
    for line in open('zgzbao_link.1.txt','r',encoding='utf-8'):
    line=eval(line)
    for m in range(2):
    sheet.write(r,m,line[m])
    r=r+1
    workbook.close()
    #从excel写入txt
    xl = xlrd.open_workbook('植保网.xlsx')
    table1 = xl.sheet_by_name(u"Sheet1")
    nr=table1.nrows
    f2= open('zgzbao_repeat.txt','w+',encoding='utf-8')
    for i in range(nr):
    row=table1.row_values(i)
    f2.write(str(row[:2])+' ')
    f2.close()
     
     
  • 相关阅读:
    break return continue
    爬虫---请求
    pycharm加开头注释
    爬虫---入门
    pip
    XML基础
    英语
    布局
    adobe
    StackOverflow
  • 原文地址:https://www.cnblogs.com/qmxj-blog/p/10235788.html
Copyright © 2011-2022 走看看