有一个给定值my = "~obr0.isnull(), ~obr1.isnull(), ~obr2.isnull(), ~obr3.isnull(), ~obr4.isnull()"
的字符串,这一行应该传递给itog = np.any(np.array([my]), axis=0)
,以便解释器像这样读取它itog = np.any(np.array([~obr0.isnull(), ~obr1.isnull(), ~obr2.isnull(), ~obr3.isnull(), ~obr4.isnull()]), axis=0)
在代码执行期间,变量“my”将被更改,然后传递给np。数组
我尝试这样做itog = np.any(np.fromstring(my, dtype='uint8'))
,但它抛出一个错误“DeprecationWarning:不推荐使用fromstring的二进制模式,因为它在unicode输入上的行为令人惊讶。使用frombuffer代替”
尝试这样做itog = np.any(np.frombuffer(my, dtype='uint8'))
,但它抛出了一个错误“TypeError:需要类似字节的对象,而不是'str'“
1条答案
按热度按时间bogh5gae1#
会做你想做的事它适用于任何返回相同类型的逗号分隔语句字符串。