1
fbichijing 2022-09-27 01:25:45 +08:00 1
Pandas 倒省事一些,openpyxl 思路应该也大同小异吧。
```python import pandas as pd data1 = [11, 22] data2 = [33, 44] data3 = [55, 66, 77, 88] df = pd.DataFrame([data1, data2, data3]) df = df.T df.to_excel('test.xlsx', index=False, header=False) ``` |
2
kkeep 2022-09-27 01:38:20 +08:00 via Android 1
补位吧
|
3
mieq 2022-09-27 02:07:44 +08:00 via iPhone 1
import openpyxl
import itertools data1 = [11, 22] data2 = [33, 44] data3 = [55, 66, 77, 88] wb = openpyxl.Workbook() ws = wb.active data = itertools.zip_longest(data1, data2, data3) for row in data: ws.append(list(row)) wb.save('test.xlsx') |
4
kkbblzq 2022-09-27 02:14:06 +08:00 1
你行列弄反了吧。。。
from openpyxl import Workbook if __name__ == "__main__": data = [ [11,22], [33,44], [55,66,77,88] ] wb = Workbook() sheet = wb.active for x in data: sheet.append(x) wb.save("test.xlsx") |