M
M
mezigar2021-07-08 15:08:05
Python
mezigar, 2021-07-08 15:08:05

Why does explicit type casting not work in python (openpyxl)?

When concatenating a string with a given string, it gives an error that only strings can be connected to each other, although there is an explicit type conversion in the program.

tempstr = ""   
for index, cell in enumerate(sheet['L']):
    tempstr += str(sheet['A' + index + 5].value)  # <-- ругается на эту строку
    if(sheet['A' + index + 5] == 'None'):
        tempstr += '/'
    tempstr +=","
print(tempstr)

Error: can only concatenate str (not "int") to str

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alan Gibizov, 2021-07-08
@mezigar

'A' + index + 5
this is str + int

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question