Python implements local find files and prints (OS for os.open chdir)

Source: Internet
Author: User

#coding: UTF-8
Import OS
B=str (raw_input (' Please enter the file to find: '))
A=str (raw_input (' Please enter the directory to find: '))
Y=1
I=[y for y in Os.listdir (a)] #列出文件和目录
#print I
#print A
c=0# set the flag bit, 0 means not found, 1 represents found. If there is no flag bit, multiple soory will be printed
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 '

Python implements local find files and prints (OS for os.open chdir)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.