【Python爬虫】第十二次作业
2017-09-03 本文已影响2人
Mango907
import os,csv
class storeCsv():
def __int__(self,path,name,content):
self.path=path
self.name=name
self.content=content
def _judge_(self,name):
if os.path.exists(name):
print('文件已存在')
else:
print('文件不存在')
def _write_(self,path,content):
fp=open(path,'a')
writer=csv.writer(fp)
writer.writerow((content))
fp.close()
test=storeCsv()
filename=input("请输入文件名字:")
test._judge_(filename)
filepath=input("请输入文件:")
filecontent=input("请输入内容:")
test._write_(filepath,filecontent)