出现问题原因如下

报错的地方告诉我了print 的地方报错了

类型不一样引起的问题

处理这个问题有2种方法

方法1: 转换类型

pi = 3
print("当前的p=" + str(pi))

方法2 使用字符串格式化

pi = 3
print("当前的p= %s" % pi)  # %s 是格式化字符串

在不知道类型的情况下建议使用字符串格式化

TypeError: can only concatenate str (not “int“) to str相关推荐

  1. Python报错can only concatenate str (not “int“) to str

    问题描述:在Pyhton中使用拼接形式去组合产生新的字符串时,报can only concatenate str (not "int") to str index =1 xml_d ...

  2. 关于 TypeError: can only concatenate str (not “int“) to str

    说明:该文属于 Python全栈白宝书专栏,免费阶段订阅数量4300+,购买任意白宝书体系化专栏可加入TFS-CLUB 私域社区. 福利:加入社区的小伙伴们,除了可以获取博主所有付费专栏的阅读权限之外 ...

  3. Python3报错:TypeError: unsupported operand type(s) for +: ‘int‘ and ‘str‘

    其实错误提示已经很明确了,"类型错误:不支持操作类型为整数和字符串",这里需要解释的最关键的东西是"+","+"在python中有两个作用, ...

  4. python unsupported operand type(s) for /: 'str' and 'str' can only concatenate str (not int) to s

    报错: TypeError: can only concatenate str (not "int") to str TypeError: unsupported operand ...

  5. can only concatenate str (not “NoneType“) to str

    原因分析: TypeError: can only concatenate str (not "int") to str,意思是不能够把一个整数和字符串进行拼接运算,即 + 运算. ...

  6. python中str,int,list,list(str),list(int)的相互转换

    python中str,int,list的相互转换 str转list list转str str转int int转str list(str)转list(int) list(int)转list(str) l ...

  7. python cannot concatenate_解决Python 异常TypeError: cannot concatenate 'str' and 'int' objects

    解决Python 异常TypeError: cannot concatenate 'str' and 'int' objects TypeError: cannot concatenate 'str' ...

  8. python运行报错TypeError: cannot concatenate 'str' and 'int' objects

    dict运行报错 d = {     'Adam': 95,     'Lisa': 85,     'Bart': 59 } for key in d:     print key+":& ...

  9. Python --提示 TypeError: cannot concatenate str and int objects

    clientsocket,addr = socketserver.accept() print("client ip:"+addr[0]) print("client p ...

最新文章

  1. Python Cookie HTTP获取cookie并处理
  2. MyBatis 插入数据库返回主键
  3. insert into value与insert into select from dual
  4. 寄存器(内存访问)07 - 零基础入门学习汇编语言19
  5. DWZ富客户端框架设计思路与学习建议
  6. 用Python识别验证码
  7. MATLAB绘图辅助操作
  8. 【重难点】【RabbitMQ 01】消息队列的作用、主流的消息队列、RabbitMQ 基于什么传输消息、RabbitMQ 模型架构、死信队列和延迟队列
  9. 通过分布式把本地图片上传到FTP(1)
  10. 写一个带输入输出的存储过程_携程大佬带你写一个可扩展的Spring插件。
  11. 将图片变换成3d对象
  12. bzoj 5084: hashit
  13. Django(五):视图和路由系统
  14. 黑马程序员前端微信小程序开发教程,微信小程序从基础到发布全流程_企业级商城实战(含uni-app项目多端部署---b站视频跟学
  15. 杏仁粉的全球与中国市场2022-2028年:技术、参与者、趋势、市场规模及占有率研究报告
  16. 1分钟搞定 OneNote自己账号扩容到15G永久免费空间
  17. 食谱生成器与营养计算器的核心部分设计
  18. rm: cannot remove `xxx’: Operation not permitted的解决方法
  19. BDTC 2017数据库上午:犹他大学、东方国信、蚂蚁金服、微软、人大金仓
  20. 2021爱分析·云计算趋势报告——支撑数字化转型,企业云平台建设进入新阶段

热门文章

  1. dev c++ 调试时候发生软件崩溃解决办法
  2. 剑指offer 40.最小的 K 个数 python代码
  3. LeetCode简单题之检查是否所有字符出现次数相同
  4. Nginx最新版安装教程(Windows+Linux)
  5. Conda安装Glossary词汇表
  6. 将TVM集成到PyTorch
  7. 什么是OpenMAX技术分析OpenMAX
  8. Python:模拟登录、点击和执行 JavaScript 语句案例
  9. Android 使用 ellipsize 实现文字横向移动效果(跑马灯效果)
  10. getCacheDir() 和 getFilesDir() 的区别