0

What is the data type of the variable data??

def write(request): if request.method == 'POST': data = request.POST with open('student.csv', 'a') as f: wrt = csv.writer(f) for key,value in data.items(): wrt.writerow( [key,value]) return render(request/form.html',('$tatus':Written'}) What is the data type of the variable data??

6th Dec 2019, 10:05 AM
Akash
Akash - avatar
8 Respuestas
+ 1
It could be dictionary, because dictionary has a the method items, which turns the dictionary into an dict_items object which is filled with lists as [key, value] pairs. {1: 1, 2: 4, 3: 27, 4: 64}.items() ---> dict_items([1, 1], [2, 4], [3, 27], [4, 64])
6th Dec 2019, 10:52 AM
Seb TheS
Seb TheS - avatar
+ 3
You can just try it: print(type(data))
6th Dec 2019, 12:53 PM
HonFu
HonFu - avatar
+ 2
HonFu since it is part of the django-project it can't be executed by itself we have to run the django development server for this, in which the output is only in form of Html pages and when I tried to get the type in html output it is showing something like type is not subscriptable (i don't remember the error message completely)
6th Dec 2019, 4:57 PM
Akash
Akash - avatar
+ 1
Seb TheS it makes sense
6th Dec 2019, 4:48 PM
Akash
Akash - avatar
0
Mirielle🐶 [Inactive] so it would be like some POST object (if thing like that exists) like we have map-object etc...
6th Dec 2019, 4:45 PM
Akash
Akash - avatar
0
HonFu the question would not have made here if that technique worked!
6th Dec 2019, 4:47 PM
Akash
Akash - avatar
0
What did you get when you tried it?
6th Dec 2019, 4:50 PM
HonFu
HonFu - avatar