如何连接字符串和整数?

How do I concatenate string and an integer?

act = input("Enter name of the activity")
cellone = int(input("Enter the order number of activity"))
cell1 = "A" + cellone
worksheet.write(cell1, act)
  

我正在尝试连接 Acellone 但我收到一些错误提示我无法连接字符串和整数,有没有办法做到这一点?

str(cellone) returns cellone 的值作为字符串。

call1="a"+str(cellone)

去掉第2行的int如下:

cellone=input("Enter the order number of activity")

无论如何它都将输入作为字符串数据类型

只是不要将字符串转换为 int。更正为

cellone=input("Enter the order number of activity")

您可以使用以下方法将 int 更改为 string 表示:

cell1="A"+str(cellone)

或者,f-string formatting 也可以:

cell1=f"A{cellone}"