开始学习Python,看了一道程序 http://www.oschina.net/code/snippet_230735_8468, 在此基础上修改了一下,
#!/bin/python
# coding:utf-8
import time
import csv
class TelBook:
def __init__(self, filename):
self._filename = filename
"""print title into file"""
csvfile = file(self._filename, "wb")
writer = csv.writer(csvfile)
title = ["NAME", "TEL", "TIME"]
writer.writerow(title)
csvfile.close()
def addPerson(self):
"""Add a new person information"""
person = raw_input("Enter the person\'s name:")
tel = raw_input("Enter the person\'s tel:")
update = time.strftime("%Y-%m-%d %H:%m:%S")
writer = csv.writer(file(self._filename, "ab"))
writer.writerow([person, tel, update])
def