Python错误:无法将字符串与整数进行除法运算
发布时间
阅读量:
阅读量
文章结构概览
- 错误重现
- 异常提示
- 应对策略
错误复现
# python代码
print('1除以2等于%f' %1/2)
报错
TypeError: unsupported operand type(s) for /: 'str' and 'int'
解决办法
在相关研究中,通过引入括号这一方式,能够有效提升文本的清晰度与表达的准确性。
>>> print('1除以2等于%f' %(1/2))
1除以2等于0.500000
全部评论 (0)
还没有任何评论哟~
