python how to print

I am very new to Python. when i run the following code I have an error on the 7 in "Python 2.7". it should be the right version. I am running Python 2.7 with psycopg2-2.6.2.win-amd64-py2.7-pg9.5.3-release.exe

Python 2.7 (r27:82525, Jul  4 2010, 07:43:08) [MSC v.1500 64 bit (AMD64)]   on win32
 Type "copyright", "credits" or "license()" for more information.

>>> import psycopg2
>>> conn1 = pymssql.connect("**", "**", "**", " **")
conn2 = pymssql.connect("**", "***", "**", "**")

cursor1 = conn1.cursor()
cursor2 = conn2.cursor()

cursor1.execute('SELECT *
FROM fiat_transactions 
 WHERE transaction_type = 'trade'
AND created_at >= '2018-02-01'
AND created_at < '2018-02-02'
ORDER BY id desc')
cursor2.execute('SELECT *
 FROM pg_orders
 WHERE id = 165025413
 OR id = 165024961
OR id = 165025409')

 result1 = cursor1.fetchall()
 result2 = cursor2.fetchall()

 for row in result1:
  print(row)

 for row in result2:
   print(row)

2 answers

  • answered 2018-05-16 04:17 wolff

    ctrl+p is a common keyboard shortcut used to send files to a printer. If you want to output something to a text file you will have to do this by telling Python to do so, as shown in this thread

  • answered 2018-05-16 04:31 K-Log

    You are trying to actually print your code like you would a text file or any other document. What you want to do is run your code. To do this, put your code into Idle(the IDE that comes with python), save it somewhere and click run(or pres F5) and your program's output should be displayed in Idle's console. If you are using the command line try python your_program.py

    You're going to want to check out the info below for more information:

    https://wiki.python.org/moin/BeginnersGuide/Programmers