Python 不支持的列表类型错误:/:';列表';和';浮动';
我有下面的代码Python 不支持的列表类型错误:/:';列表';和';浮动';,python,python-3.x,list,Python,Python 3.x,List,我有下面的代码 def latency(i): layer_macc = profile(model) #new_list=[float(i) for i in layer_macc] macc_layer=layer_macc[i] return macc_layer/(3.84*pow(10,11)) 当我试着运行代码时,我发现下面的错误 TypeError: unsupported operand type(s) for /: 'list' and 'float'
def latency(i):
layer_macc = profile(model)
#new_list=[float(i) for i in layer_macc]
macc_layer=layer_macc[i]
return macc_layer/(3.84*pow(10,11))
当我试着运行代码时,我发现下面的错误
TypeError: unsupported operand type(s) for /: 'list' and 'float'.
我试图将列表转换为float,但仍然不起作用
谢谢替换最后两行:
x=3.8*pow(10,11)
return [f/x for f in macc_layer]
你认为将
列表
除以浮点数
应该做什么?您希望将列表
转换为浮动
会是什么?