将ui选择的值转换为整数列表

时间:2016-08-09 13:02:30

标签: python angularjs list

我使用了 angular-ui-select ,正在选择一些像这样的int类型的ID 9,2,3。我正在尝试将这些值作为integer列表传递给python文件,如此

param += '"lstRole":[' + $scope.multipleDemo.roles +']';

抛出错误

Nonetype object is not iterable

当我把这个参数传递给

param += '"lstRole":"[' + $scope.multipleDemo.roles +']"';

它收到字符串列表并抛出错误

invalid literal for int() with base 10

任何人都可以提到我的错误吗?

1 个答案:

答案 0 :(得分:0)

在你的python函数中尝试这个:

json_str = request.body.decode('utf-8')        
py_str = json.loads(json_str)

print(py_str["lstRole"])