How can I redirect print function to an output file?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Plissken.s@gmail.com

    #1

    How can I redirect print function to an output file?

    I am using the print function in my python script.
    Can you please tell me what can I do to redirect the output to an file?

    Thank you.

  • Enoodle@gmail.com

    #2
    Re: How can I redirect print function to an output file?

    Learn the basics of binary files in Python. Discover how to read and write binary files, and the different file modes available for binary files.


    example 10.9 , redurectung output

    Comment

    • Alex Martelli

      #3
      Re: How can I redirect print function to an output file?

      <Plissken.s@gma il.com> wrote:
      [color=blue]
      > I am using the print function in my python script.
      > Can you please tell me what can I do to redirect the output to an file?[/color]

      f = open('aaaaaaarg h', 'w')
      print>>f, 'killew wabbit'


      Alex

      Comment

      Working...