• python读取excel以及python全套安装


    python安装:python2于python3的语法不一样,我都不会,建议安装python3,在安装时记得添加环境变量,python的卸载也是用安装包卸载的,其他过程略

    pycharm安装:开源版,装上就行

    pip安装(管理扩展包之类的东西,有了这个才可以读excel):这篇亲测有效,其他的看起来都很麻烦 传送门

    使用包的时候需要在pycharm中添加进去,参照这篇

    excel的使用方法,这里是关于python3的,写的挺清楚的(传送门

    下面是我自己写的关于python读写excel的代码:

     算了太懒了

    import xlwt
    import xlrd
    import openpyxl
    
    name = "test.xlsx"
    book = xlrd.open_workbook(name)
    sheet = book.sheet_by_index(0)
    n = sheet.nrows
    m = sheet.ncols
    
    newbook = openpyxl.Workbook()
    newsheet = newbook.get_active_sheet()
    
    cnt = 1;
    for i in range(1, n + 1) :
        for j in range(1, m + 1) :
            newsheet.cell(cnt + i - 1, j, sheet.cell(i - 1, j - 1).value)
    cnt += n;
    
    name = "test1.xlsx"
    book = xlrd.open_workbook(name)
    sheet = book.sheet_by_index(0)
    n = sheet.nrows
    m = sheet.ncols
    for i in range(1, n + 1) :
        for j in range(1, m + 1) :
            newsheet.cell(cnt + i - 1, j, sheet.cell(i - 1, j - 1).value)
    cnt += n
    newbook.save("test2.xlsx")
    print("success")
  • 相关阅读:
    用IIS做宿主的WCF服务
    Apache+mono+xsp搭建Linux下的asp.net平台
    web页面中的卡片布局代码
    GridView内的数据循环滚动
    adb 无法启动问题
    User interface
    动态生成linearLayout
    跳转到下一个activity
    android studio 快捷键
    [转]项目失败的经验
  • 原文地址:https://www.cnblogs.com/lalalatianlalu/p/10387289.html
Copyright © 2020-2023  润新知