简体   繁体   English

Python列表包含3个元素,但我只能访问最后一个元素

[英]Python list has 3 elements but I can only access the last element

I am processing a POST request in a django view and am expecting a list of strings in one of the dictionary elements. 我正在django视图中处理POST请求,并期望其中一个字典元素中的字符串列表。 I'm using Pycharm to debug the code and I can see that in the dictionary, 3 values are returned but when I try to access that dictionary element, I can only access the last item in the list. 我正在使用Pycharm调试代码,可以看到在字典中返回了3个值,但是当我尝试访问该字典元素时,我只能访问列表中的最后一项。

Pycharm的代码

I'm hoping it's a typecast issue of some sort perhaps? 我希望这可能是某种类型转换问题?

The filepond dictionary is a 3rd party java library I'm using so I have no control over how it gets POSTed back to django. filepond字典是我正在使用的第三方Java库,因此我无法控制它如何回发到Django。

Try using: 尝试使用:

my_list = self.request.POST.getlist('filepond')

Read more about it in Django's Official Documentation . Django的官方文档中阅读有关它的更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 只能访问Python unicode字典中列表的最后一个元素 - Able to access only last element of list in Python unicode dictionary Python-传递带有元素的列表,但是我只获得列表中的第一个元素 - Python - Passing a list with elements, but I only get the first element in the list 在Python中,如何存储列表的最后一个元素? - In Python, how can I store the last element of a list? Python 列表理解 - 访问最后创建的元素? - Python list comprehension - access last created element? Python词典列表仅查看最后一个元素 - Python List of Dictionaries Only See Last Element Python:For 循环仅打印列表的最后一个元素 - Python: For loops print only last element of a list 如何在字典python中访问列表中的元素? - How can I access elements inside a list within a dictionary python? 仅从在python中元素开头具有任何数量的列表中获取元素 - Only get the elements from a list that has any kind of quantity in the beginning of the element in python 我想打印列表中添加的所有元素,但它只打印最后一个元素。(Python) - I want to print all the element added in list but it is only printing the last element.(Python) 将字符串与list元素连接在一起仅返回最后一个元素 - concatenating a string with elements of list returns only the last element
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM