python编程时报错了这样该怎么办啊

Traceback (most recent call last):
File "<pyshell#2>", line 1, in
S=4PIr*r
TypeError: can't multiply sequence by non-int of type 'float'

报错是说遇到非整数的浮点数导致不能进行相乘的运算,出错是因为数据类型不对,因此解决办法就是转换数据类型,检查下之前的代码
4PIrr是不是写错了4P才是相乘

TypeError: can't multiply sequence by non-int of type 'float'

这个错误是说非整数的浮点数不能进行相乘
检查下你PI或者r的值是不是字符串

比如你r是用户输入的,用input()读取的是字符串。要用int()或float()转成数值才行

PI = 3.14
r = float(input("输入r:")) #input()读取的是字符串。要用int()或float()转成数值才行

S=4*PI*r*r
print(S)

img

如有帮助,请点击我的回答下方的【采纳该答案】按钮帮忙采纳下,谢谢!

img

你这个4P之间要加星号