Python Forum
Remove double quotes from the list ?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Remove double quotes from the list ?
#6
(Oct-31-2020, 06:20 PM)bowlofred Wrote: Before line4, if you add this, what is the output? I can't tell where your v_str_sev is getting its data.

print(type(v_str_sev))
If it's a str, then you need to figure out where the data is coming from and fix it there.

The output is :
 <class 'str'>
And when I press the variable (v_str_sev), the result I have is exactly this:
   print(v_str_sev)
   -> MiniFieldStorage('v_name', 'João'), MiniFieldStorage('v_sname', 'Aguiar')
Note that there are no double quotes at the beginning and end.

Double quotes appear only when I re-string the string by inserting the variable (v_str_sev) between the brackets as the value of the attribute (list) of the instantiated v_field object of the FieldStorage class, as shown in the example below :
   from cgi import FieldStorage
   v_field = FieldStorage()
   v_field.list = [v_str_sev]
   print(v_field)

   -> FieldStorage(None, None, ["MiniFieldStorage('v_name', 'João'), MiniFieldStorage('v_sname', 'Aguiar')"])
Note that the data type is now, that it is almost correct, missing the double quotes from the beginning and end ?
   <class 'cgi.FieldStorage'>
   -> FieldStorage(None, None, ["MiniFieldStorage('v_name', 'João'), MiniFieldStorage('v_sname', 'Aguiar')"])
Reply


Messages In This Thread
Remove double quotes from the list ? - by PythonDev - Oct-31-2020, 01:12 AM
RE: Remove double quotes from the list ? - by PythonDev - Nov-01-2020, 01:40 AM
RE: Remove double quotes from the list ? - by buran - Nov-01-2020, 09:18 PM
RE: Remove double quotes from the list ? - by buran - Nov-02-2020, 08:36 AM
RE: Remove double quotes from the list ? - by buran - Nov-02-2020, 05:41 PM
RE: Remove double quotes from the list ? - by buran - Nov-02-2020, 05:49 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  remove duplicates from dicts with list values wardancer84 27 6,786 May-27-2024, 04:54 PM
Last Post: wardancer84
  unable to remove all elements from list based on a condition sg_python 3 1,834 Jan-27-2024, 04:03 PM
Last Post: deanhystad
  Remove numbers from a list menator01 4 4,004 Nov-13-2022, 01:27 AM
Last Post: menator01
  Reading list items without brackets and quotes jesse68 6 7,255 Jan-14-2022, 07:07 PM
Last Post: jesse68
  Remove empty keys in a python list python_student 7 6,082 Jan-12-2022, 10:23 PM
Last Post: python_student
  Remove an item from a list contained in another item in python CompleteNewb 19 9,314 Nov-11-2021, 06:43 AM
Last Post: Gribouillis
  Remove single and double quotes from a csv file in 3 to 4 column shantanu97 0 8,834 Mar-31-2021, 10:52 AM
Last Post: shantanu97
  Two types of single quotes Led_Zeppelin 2 2,725 Mar-15-2021, 07:55 PM
Last Post: BashBedlam
  .remove() from a list - request for explanation InputOutput007 3 3,132 Jan-28-2021, 04:21 PM
Last Post: InputOutput007
  Remove specific elements from list with a pattern Xalagy 3 3,768 Oct-11-2020, 07:18 AM
Last Post: Xalagy

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020