FInd files with .so extension

S

Steven D'Aprano

HI,


How do i find files with .so extension using python .



import os
help(os.listdir)
help(os.walk)
help(os.path.splitext)


That should give you all the tools you need.
 
K

kaens

do YOU mean hit "reply to all" not "reply?"

do you mean
filelst.append(i)?

May be this would work
import os
grep="so"
dir="."
lst = os.listdir(dir)
filelst=[]
for i in lst:
if i.split(".")[len(i.split("."))-1] == grep:
lst.append(i)
print lst



HI,


How do i find files with .so extension using python .



--
Regards--
Rishi Pathak
National PARAM Supercomputing Facility
Center for Development of Advanced Computing(C-DAC)
Pune University Campus,Ganesh Khind Road
Pune-Maharastra
 
P

pradeep nair

do YOU mean hit "reply to all" not "reply?"

do you mean
filelst.append(i)?
May be this would work
import os
grep="so"
dir="."
lst = os.listdir(dir)
filelst=[]
for i in lst:
if i.split(".")[len(i.split("."))-1] == grep:
lst.append(i)
print lst
HI,
How do i find files with .so extension using python .
--
http://mail.python.org/mailman/listinfo/python-list
--
Regards--
Rishi Pathak
National PARAM Supercomputing Facility
Center for Development of Advanced Computing(C-DAC)
Pune University Campus,Ganesh Khind Road
Pune-Maharastra

????
 
M

mailme.gurpreet

HI,

How do i find files with .so extension using python .

Hi pradeep


This piece of code should help you


import os,re

def findfile(filepattern, base = '.'):
regex = re.compile(filepattern)
matches = []
for root,dirs,files in os.walk(base):
for f in files:
if regex.match(f):
matches.append(root + '/' + f)
return matches


HAPPY CODING
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,681
Members
48,796
Latest member
Greg L.

Latest Threads

Top