Python note

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()

Recommended Posts

Note: Python
Python note
Python study note_002
Note: Python Decorator
[Python] Learning Note 1
Python study note_004
Python study note_003
[Note] openCV + python
Python beginner's note
Note
[Note] future sentence ~ Python ~
[Note] File reading ~ Python ~
Note
Note
Note to daemonize python
Python basic grammar note (4)
Python basic grammar note (3)
Python Tkinter Primer Note
Python Input Note in AtCoder
[Note] Operate MongoDB with Python
[WIP] Fluent Python Study Note
3 months note for starting Python
[AtCoder] ABC165C Personal Note [Python]
Note that it supports Python 3
A note about [python] __debug__
kafka python
Django note 4
Python basics ⑤
python + lottery 6
Python Summary
Python comprehension
Python technique
pyenv note
Python Note: About comparison using is
Studying python
Python memorandum
Python FlowFishMaster
Python service
python tips
[Note] Project Euler in Python (Problem 1-22)
python function ①
Python basics
Python memo
ufo-> python (3)
Python comprehension
GroupBy Note
install python
Python Singleton
Python basics ④
Python Memorandum 2
python memo
Python: A Note About Classes 1 "Abstract"
Python Jinja2
Python increment
atCoder 173 Python
[Python] function
Python installation
python tips
Installing Python 3.4.3.
Try python
Python memo