相关疑难解决方法(0)

Python String和Integer连接

我想在for循环中使用附加到它的整数创建字符串.像这样:

for i in range(1,11):
  string="string"+i
Run Code Online (Sandbox Code Playgroud)

但它返回一个错误:

TypeError: unsupported operand type(s) for +: 'int' and 'str'
Run Code Online (Sandbox Code Playgroud)

连接String和Integer的最佳方法是什么?

python string integer concatenation

330
推荐指数
6
解决办法
63万
查看次数

标签 统计

concatenation ×1

integer ×1

python ×1

string ×1