0

I created a looped program (with selenium chromedriver), which on each restart should read me in the next cell. unfortunately I can't. I had tried the following solution, unfortunately the following error obviously appears:

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

to summarize it is only part of the code:

while

number=1

sh1=wb['Example']
sheet=sh1["A"+ number].value  #sheet A1 not work
print(sheet)

number +=1

Ay intent is to read after each reopening of the program: the first time in cell A1, the second time in cell A2 and so on...

lolino
  • 97
  • 1
  • 8
  • Does this answer your question? [How can I concatenate str and int objects?](https://stackoverflow.com/questions/25675943/how-can-i-concatenate-str-and-int-objects) – Mike Scotty Mar 29 '21 at 15:26

1 Answers1

1

The error message says it: you have to cast number as a string.

So adding sheet=sh1["A"+ str(number)].value should do.

luanpo1234
  • 300
  • 1
  • 7