sqlite - Is it possible to separate multiple values pulled in from a SQLite3 Row using Python? -
i have database row links, example, name mike description blonde, short, glasses. current, if run person.description, prints out this:
" ""blonde""", 'short', 'glasses',
is possible separate these values , eliminate '"'s? here few things i've tried:
in person: j in i['description']: print j
this returns each descriptive word character character:
" " " b l o n d e " " " ,
next tried:
for in plugins: print i['sets_kb_item']
this returned:
" ""blonde""", 'short', 'glasses',
i've tried this, trying lucky:
in person: j in i: print j['description']
but gave me typeerror:
typeerror: 'int' object has no attribute '__getitem__'
here example of row in sqlite database querying:
name: description: mike 'blonde', "" """"short"""""", 'glasses',"
and here query i'm using:
cur = db.execute("select * person description ?", (query,))
my end goal have output prints like:
name: mike - blonde - short - glasses
ultimately, need revisit heck went on when imported these values db, there can until then?
lets have variable:
a = "\"\"blonde\"\""
now when print it, you'll see this
""blonde""
to remove '"', i'd this,
b=a.strip('\"') print(b)
this print:
blond
to separate on ',' , should split,
c=a.split(',')
where c
become array:
['blonde', 'short', 'glasses']
this gave array elements, can amount of processing want.
so total code considering input string:
a=a.strip('\"').split(',') x in a: print(a)
i hope helps problem.
Comments
Post a Comment