Home > other >  Python NoneType problem
Python NoneType problem

Time:10-07

Here is my program, and then to give wrong inside, who is a great god can help me have a look, I'm a beginner, for these are not particularly understand
The mistake is this appearance of

Traceback (the most recent call last) :
The File "E:/Neil/Code/Python/excel. Py", line 19, in & lt; module>
The sum +=item
TypeError: unsupported operand type (s) for +=: 'int' and 'NoneType'
1581
0

This part is the code below, its position, the winning red is tell the location of the error code compiler

# coding=utf-8
The from openpyxl import load_workbook
# d=ws. Cell (row=3, column=0)
Workbook_=load_workbook (' e.x LSX ') # import worksheet
Sheetnames=workbook_. Get_sheet_names () # form name
Sheet=workbook_. Get_sheet_by_name (sheetnames [0]) # extract a form from the worksheet
arrdata=https://bbs.csdn.net/topics/[] # defines a list
Sum=0
For rowNum in range (4, 30) :
For colNum in range (4, 26) :
Data=https://bbs.csdn.net/topics/sheet.cell (rowNum=row, column=colNum). The value
Arrdata. Append (data)
For the item in arrdata:
sum +=item
Print (sum)
Sum=0
Print (sum)
[] arrdata=https://bbs.csdn.net/topics/

CodePudding user response:

Item get a null value, can't and int addition
The
The sum +=item
Change
If the item: sum +=item
Excel operation is not easy, needs to be treated with caution

CodePudding user response:

Free range in value
  • Related