j=88.87
我想用eval来做这个:
data_88_87=data_88_87.append(data[data['norm']==88.87])
但是:
eval('data_'+str(j).replace('.','_'))=eval('data_'+str(j).replace('.','_')).append(data[data['norm']==j])
File "<ipython-input-110-a69e45d994b1>", line 5
eval('data_'+str(j).replace('.','_'))=eval('data_'+str(j).replace('.','_')).append(data[data['norm']==j])
^
SyntaxError: can't assign to function call
eval('data_'+str(c).replace('.','_')+'='+('data_'+str(c).replace('.','_')).append(data[data['norm']==j]))
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-121-64d2b5d27c76> in <module>()
----> 1 eval('data_'+str(c).replace('.','_')+'='+('data_'+str(c).replace('.','_')).append(data[data['norm']==2.98]))
AttributeError: 'str' object has no attribute 'append'
使用eval时如何使用df.appen
您可以按如下方式使用它:
以上代码将为您提供以下输出:
相关问题 更多 >
编程相关推荐