Найти - Пользователи
Полная версия: TypeError: 'int' object is not callable
Начало » Python для новичков » TypeError: 'int' object is not callable
1
Antonpython
Добрый день! Набирал в интерактивной оболочке команду:

Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) on win32
Type “copyright”, “credits” or “license()” for more information.



>>> import openpyxl
>>> import os
>>> os.chdir(r“C:\Users\Anton\Desktop\Python”)
>>> wb = openpyxl.load_workbook('produceSales.xlsx')
>>> wb = openpyxl.load_workbook('produceSales.xlsx')
>>> sheet = wb.get_sheet_by_name('Sheet')
>>> PRICE_UPDATES = {'Kale': 234,'Grapes': 235,'Apples':236 }
>>> for rowNum in range(2, sheet.get_highest_row()):
produceName = sheet.cell(row=rowNum, column=1).value
if produceName in PRICE_UPDATES:
sheet.cell(row=rowNum, column=2).value = PRICE_UPDATES
wb.save('updatedProduceSales.xlsx')

Выдало сообщение:

Traceback (most recent call last):
File “<pyshell#14>”, line 1, in <module>
for rowNum in range(2, sheet.get_highest_row()):
AttributeError: ‘Worksheet’ object has no attribute ‘get_highest_row’


Потом заменил:

get_highest_row()) на sheet.max_row()):

Выдало новую
Traceback (most recent call last):
File “<pyshell#21>”, line 1, in <module>
for rowNum in range(2, sheet.max_row()):
TypeError: ‘int’ object is not callable
>>>

но программу не выполнило.


Подскажите, пожалуйста, где моя ошибка?



wallet
 for rowNum in range(2, sheet.max_row):
Antonpython
Не знаю… не хочет…

>>> import openpyxl
>>> import os
>>> os.chdir(r“C:\Users\Anton\Desktop\Python”)
>>> wb = openpyxl.load_workbook('produceSales.xlsx')
>>> sheet = wb.get_sheet_by_name('Sheet')
>>> PRICE_UPDATES = {'Kale': 234,'Grapes': 235,'Apples':236 }
>>> for rowNum in range(2, sheet.max_row):
produceName = sheet.cell(row=rowNum, column=1).value
if produceName in PRICE_UPDATES:
sheet.cell(row=rowNum, column=2).value = PRICE_UPDATES
wb.save('updatedProduceSales.xlsx')


Traceback (most recent call last):
File “<pyshell#11>”, line 4, in <module>
sheet.cell(row=rowNum, column=2).value = PRICE_UPDATES
File “C:\Users\Anton\AppData\Local\Programs\Python\Python36\lib\site-packages\openpyxl\cell\cell.py”, line 292, in value
self._bind_value(value)
File “C:\Users\Anton\AppData\Local\Programs\Python\Python36\lib\site-packages\openpyxl\cell\cell.py”, line 201, in _bind_value
raise ValueError(“Cannot convert {0} to Excel”.format(value))
ValueError: Cannot convert {'Kale': 234, ‘Grapes’: 235, ‘Apples’: 236} to Excel
>>>
Antonpython
Подскажите, как отладить???
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB