#coding:UTF-8
import os
b=str(raw_input('请输入要查找的文件:'))
a=str(raw_input('请输入要查找的目录:'))
y=1
i=[y for y in os.listdir(a)]#列出文件和目录
#print i
#print a
c=0#设置标志位,0代表没有找到,1代表找到。如果没有标志位,则会打印多个soory
for x in i:
#print x
if x==b:
c=1
print 'yes,it is here.the content as follow:'
os.chdir(a)#更改当前目录
d=open(b)#打开文件
e=d.read()#读取文件
print e
if c==0:
print 'sorry,not find'

posted on 2017-03-06 11:18  watermelon-lf  阅读(1229)  评论(0编辑  收藏  举报