Python fpdf2: AttributeError ⇐ Python

Программы на Python
Anonymous
Python fpdf2: AttributeError

Сообщение Anonymous »

Когда я пробую этот код с использованием FPDF:

Код: Выделить всё

from fpdf import FPDF
table_data = (
('Producer', 'Series/Line', 'Wine Name', 'Grape(s)', 'Year', 'Age', 'On Hand'),
('IT CN/331', '', 'Barolo Legato', 'Nebbiolo', '2015', '8y, 11m, 16d', 1, '1 left of 1 stocked'),
('John Galt', '', 'Cabernet Sauvignon', 'Cabernet Sauvignon', '2016', '7y, 11m, 16d', 1, '1 left of 1 stocked'),
('Santos Lima', '', 'Confidencial Reserva', 'Red Blend', '2017', '6y, 11m, 16d', 3, '3 left of 4 stocked'),
)
pdf = FPDF(unit="in", format="Letter")
pdf.add_page()
pdf.set_margins(left=0.75, top=0.75, right=0.75)
pdf.set_font("helvetica", size=10)
with pdf.table() as table:
for tupl in table_data:
row = table.row()
for value in tupl:
row.cell(value)
pdf.output("C:\\Users\\Paul\\Dropbox\\Work\\ProgrammingProjects\\cellar\\x.pdf")
Я получаю сообщение об ошибке:

Код: Выделить всё

AttributeError: 'int' object has no attribute 'encode'
Я пытаюсь следовать примеру https://py-pdf.github.io/fpdf2/Tables.html.
Что неправильно, и как это исправить?

Подробнее здесь: https://stackoverflow.com/questions/790 ... ibuteerror

Вернуться в «Python»