writing to a file in python

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bartonc
    Recognized Expert Expert
    • Sep 2006
    • 6478

    #16
    Originally posted by akbkgp
    Thanks for the script, I almost succeed to write a similar m file for my python code. Now I'm having a problem, suppose I want to write the file with some specific no.s/characters previously defined in .py file. str() doesn't help me feeding the data to the m file to be written, what's the procedure ? Thanks.
    [code=python]import time,os
    month,day=time. strftime("%m %d",time.localt ime()).split()
    dir2create=os.p ath.join("/home/somedir2create" )
    os.mkdir(dir2cr eate)
    os.chdir(dir2cr eate)
    astring = """
    <html>
    <body>
    Blah Blah
    </html>
    """
    theFile = open("%s%s"%(mo nth,day),"a")
    theFile.write(a string)
    theFile.close()
    [/code]

    Comment

    • akbkgp
      New Member
      • Sep 2007
      • 2

      #17
      thanks for the help, I haven't checked the place for long.

      Comment

      Working...