Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Format SQL Query Output
#3
rows is list of tuples. By print(*i) you just unpack each tuple into print and the default separator is space.
The simplest solutions is to specify sep argument to print function
print(*i, sep=',')
There are other options like using str.join() or string formatting. These would be helpful if you want to construct a string and assign it to a name.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
Format SQL Query Output - by phillyfa - Apr-21-2020, 07:23 PM
RE: Format SQL Query Output - by Larz60+ - Apr-21-2020, 08:06 PM
RE: Format SQL Query Output - by buran - Apr-22-2020, 07:45 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Query output in Tuple paulo79 2 2,002 Apr-07-2022, 12:54 PM
Last Post: paulo79
  format the output from a nested dictionary. nostradamus64 9 4,623 May-03-2021, 04:45 PM
Last Post: nostradamus64
  JupyterLab Dictionary Content Output Format Ourkid123uk 0 1,326 Sep-04-2020, 02:18 PM
Last Post: Ourkid123uk
  MYSQL Update Query format simdo01 1 2,245 Aug-31-2020, 12:59 AM
Last Post: nilamo
  str.endswith Output Query eddywinch82 8 3,886 Aug-21-2020, 11:59 PM
Last Post: eddywinch82
  Save output into a Excel Sheet with Format Table skaailet 1 2,521 Apr-17-2020, 11:56 PM
Last Post: thirteendec
  Display output in readable format and save hnkrish 1 2,656 Jul-19-2019, 09:29 AM
Last Post: Larz60+
  About the output format. shang2019 4 2,730 Jan-10-2019, 07:38 PM
Last Post: buran
  python script to get wildcard mask output in the following format techrichit 0 3,839 Aug-10-2018, 11:01 PM
Last Post: techrichit

Forum Jump:

User Panel Messages

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