Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Query output in Tuple
#3
(Apr-07-2022, 12:31 PM)buran Wrote: the query result is consists of one-element tuples. You can always access the first element in each tuple by dgname[0], or create a list with all first elements

spam=(('DATA',),('RECO',))
eggs = next(zip(*spam)) # eggs = list(zip(*spam))[0]
print(eggs)
print('\n'.join(eggs))

Thanks a lot, I'm so new to this :)
Reply


Messages In This Thread
Query output in Tuple - by paulo79 - Apr-07-2022, 12:13 PM
RE: Query output in Tuple - by buran - Apr-07-2022, 12:31 PM
RE: Query output in Tuple - by paulo79 - Apr-07-2022, 12:54 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  code with no tuple gets : IndexError: tuple index out of range Aggam 4 3,019 Nov-04-2020, 11:26 AM
Last Post: Aggam
  str.endswith Output Query eddywinch82 8 4,045 Aug-21-2020, 11:59 PM
Last Post: eddywinch82
  Format SQL Query Output phillyfa 2 4,265 Apr-22-2020, 07:45 AM
Last Post: buran
  How to get first line of a tuple and the third item in its tuple. Need Help, Anybody? SukhmeetSingh 5 3,401 May-21-2019, 11:39 AM
Last Post: avorane
  Sqlalchemy Query into tuple KirkmanJ 0 2,561 Jul-10-2018, 02:56 PM
Last Post: KirkmanJ

Forum Jump:

User Panel Messages

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