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

 时间:2026-02-15 16:52:18

1、首先翻译下报错的英文,只能把字符串和字符串连接在一起(而不是整型)

can only concatenate str (not

2、接着定位发生报错的文件行号和语句

can only concatenate str (not

3、我们做一下修改,这里把整型11改成字符串11

can only concatenate str (not

4、这次运行就正常了,不再报错

can only concatenate str (not

5、还要些小伙伴遇到的是另一个报错,看着不一样,其实是一个意思

TypeError: unsupported operand type(s) for +: 'int' and 'str'

can only concatenate str (not

6、前面那个错误是因为用字符串加了整型,这个报错是因为你用整型去加了字符串

can only concatenate str (not

  • python读取txt文件内容
  • python怎么打开ipynb文件
  • PyCharm怎么安装第三库或模块
  • python中如何提取一组数据中的第一列数据
  • anaconda运行python程序教程
  • 热门搜索
    怎么删除页眉页脚 莲藕怎么做好吃 snkrs怎么抽签 j怎么读 下水道堵了怎么办 梦幻西游怎么赚钱 开红酒没有开瓶器怎么办 胃胀打嗝怎么办 燕窝是怎么形成的 自卑怎么办