我试图将每个单元格内的值增加1
import openpyxl as xl
from openpyxl import Workbook
wb = Workbook()
sheet = wb['Sheet']
age = sheet.cell(row=1, column=1, value='age')
gender = sheet.cell(row=1, column=2, value='gender')
genre = sheet.cell(row=1, column=3, value='genre')
val = 20
for row in range(2, 11):
cell = sheet.cell(row=row, column=1)
cell.value(val)
wb.save('music.xlsx')
我一直收到一个错误:
line 14, in <module>
cell.value(val)
TypeError: 'NoneType' object is not callable
我知道我的代码中有很多错误,但是我不知道如何修复它
在cell对象中,value不是方法,而是属性
因此,请使用以下代码:
相关问题 更多 >
编程相关推荐