LoginSignup
0
0

More than 5 years have passed since last update.

Python note

Last updated at Posted at 2017-03-27

Basic

hello.py
#!/bin/python

print "Hello World"
$ ./hello.py
Hello World

File

file.py
#!/bin/python

import os.path

if os.path.isfile("error.log"):
        os.remove("error.log")
else:
        print "Doesn't exist"
write.py
#!/bin/python

# overwrite
log = open('access.log', 'w')
log.write("ABCD\n")
log.close()

# append write
log = open('access2.log', 'a+')
log.write("ABCD\n")
log.close()
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0