1、openpyx(仅适用于xlxs格式):
https://www.cnblogs.com/heshun/p/10426609.html
2、xlrd/xlwt(适用于xls/xlxs格式):
https://blog.csdn.net/csdnnews/article/details/80878945
https://www.jianshu.com/p/d596ba8931ee
安装失败:https://www.cnblogs.com/jiyanjiao-702521/p/9960071.html
import xlrd import xlwt def read(excel_path): wb = xlrd.open_workbook(excel_path) sheet = wb.sheet_by_name('sheet表1') rows = sheet.nrows # 获取总行数 print(sheet.row_values(1)[2]) # 获取第一行第二列值(从0开始) def write(excel_path): wb = xlwt.Workbook() sheet = wb.add_sheet('test_sheet') sheet.write(2, 5, '测试') # 将“测试”字符串写入第二行第五列(从0开始) wb.save(excel_path) if __name__ == '__main__': path = 'E:JarvisPython\api-auto\temp_test\哈哈.xlsx' read(path) new_path = 'test.xlsx' write(new_path)
3、xlutiles
pip install xlutils-i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
pip安装:https://blog.csdn.net/hzk594512323/article/details/86082852
xlutils用法:https://blog.csdn.net/u013176681/article/details/51119071