Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

find all html files in a current directory using regular expression in python

import re
import os
currentdir = os.getcwd()
files = os.listdir(currentdir)
pattern = "^.*html$"
prog = re.compile(pattern)
htmlfiles=[]
for file in files:
    result = prog.findall(file)
    if len(result)!=0:
        htmlfiles.append(result[0])

for htmlfile in htmlfiles:
    print(htmlfile)

Comment

PREVIOUS NEXT
Code Example
Python :: odoo 13 vs code 
Python :: install python 3.10 pip 
Python :: pyt last of range of numbers 
Python :: cmd python script stay open 
Python :: ax text not placed correclty 
Python :: find not in dafatrame series 
Python :: Broadcasting with NumPy Arrays Example 
Python :: Python NumPy rollaxis Function Syntax 
Python :: jupyter extension 4 
Python :: python f strings 
Python :: sensitivity 
Python :: Python NumPy ascontiguousarray Function Example List to an array 
Python :: Python NumPy dstack Function Example 01 
Python :: watchlist flask app 
Python :: SciPy KDTrees 
Python :: Python __le__ 
Python :: how to get defintiion of pysspark teable 
Python :: count matching in two strings 
Python :: NumPy packbits Code Packed array along axis 1 
Python :: ttk.frame 
Python :: python restrict function parameter type 
Python :: Remove Brackets from List Using the * operator with the Separator method 
Python :: unauthorized vue django rest framework 
Python :: Compress multiple directories but exclude directory - Python zipfile(or anything native to Windows 2012+ 
Python :: how to aggregate and add new column 
Python :: tkinter screen clicked 
Python :: How to solve import errors while trying to deploy Flask using WSGI on Apache2 
Python :: walrus with ternary python 
Python :: ring For in Loop 
Python :: Select right color to threshold and image with opencv 
ADD CONTENT
Topic
Content
Source link
Name
1+4 =