Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/282.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python ujson无法对numpy数组进行编码_Python_Json_Python 3.x_Ujson - Fatal编程技术网

Python ujson无法对numpy数组进行编码

Python ujson无法对numpy数组进行编码,python,json,python-3.x,ujson,Python,Json,Python 3.x,Ujson,numpy阵列 x = np.array([1,2,3,4]) ujson.encode ujson.encode(x, ensure_ascii=False, double_precision=-1) 给我一个错误 OverflowError: Maximum recursion level reached 版本信息 ujson 1.33 python 3.4.3 似乎ujson无法对numpy数组进行编码,并给出令人困惑的错误消息 顺便问一下,我在哪里可以找到ujson的文档。thx

numpy阵列

x = np.array([1,2,3,4])
ujson.encode

ujson.encode(x, ensure_ascii=False, double_precision=-1)
给我一个错误

OverflowError: Maximum recursion level reached
版本信息

ujson 1.33
python 3.4.3
似乎ujson无法对numpy数组进行编码,并给出令人困惑的错误消息


顺便问一下,我在哪里可以找到ujson的文档。thx

在jsonification之前,请确保将任何numpy数组转换为常规列表。因此,

ujson.encode(x.tolist())
应该可以工作(Python 3.5.3;ujson 1.35)

ujson文档:

顺便说一句,对于你所描述的,有一个很好的解释