【已解决】Object of type 'range' is not JSON serializable
2017-09-01 12:34
507 查看
报错:提示range类型的队形不是一个JSON序列
看一看问题出现在哪里,我这是按照自强学堂里面做的
自强学堂-Ajax
以下是我的
def ajax_list(request):
a = range(100)
return JsonResponse(a, safe=False)
完全一毛一样啊....
所以问题应该就出现在Python的版本上,我用的是Python3.6.2
所以Python3.X和2.X的range()用法是不一样的
def ajax_list(request):
a = list(range(100))
return JsonResponse(a, safe=False)
改成这样即可执行..
相关文章推荐
- python2.7web代码用python3.6运行时,浏览器发送请求报错TypeError: Object of type 'bytes' is not JSON serializable的解决办法
- 【已解决】Object of type 'QuerySet' is not JSON serializable
- TypeError: Object of type 'float32' is not JSON serializable
- 在使用json.dumps时遇到报错TypeError: Object of type 'float32' is not JSON serializable
- TypeError: Object of type 'bytes' is not JSON serializable
- TypeError: datetime.datetime(2016, 9, 25, 21, 12, 19, 135649) is not JSON serializable解决办法(json无法序列化对象的解决办法)
- django object is not JSON serializable error问题解决
- datetimeTypeError: datetime.datetime(2015, 1, 29, 8, 17, 41) is not JSON serializable
- 关于 "Uncaught TypeError: Property 'submit' of object #<HTMLFormElement> is not a function" 的解决方案
- [scrapy] exceptions.TypeError:XXX is not json serializable
- Operation is not valid due to the current state of object 错误解决
- 解决Uncaught TypeError: object is not a function
- mongoDB add user in v3.0 问题的解决(Property 'addUser' of object admin is not a func)
- How to solve 'object of abstract class type "newFoo" is not allowed'?
- object is not an instance of declaring class&argument type mismatch
- 错误: java.io.NotSerializableException: net.sf.json.JSONObject 的解决方法
- parameter "bandwidth_type" is not a formal parameter of instantiated module的解决方法
- object of abstract class type "我的类" is not allowed 解决方案
- object is not an instance of declaring class while invoking public abstract…的解决
- Python 出现错误TypeError: ‘NoneType’ object is not iterable解决办法