Answers for "python loop files"

10

python loop through files in directory

import os

for filename in os.listdir(directory):
    if filename.endswith(".asm") or filename.endswith(".py"): 
         # print(os.path.join(directory, filename))
        continue
    else:
        continue
Posted by: Guest on May-11-2020
1

loop through file python

with open('topology_list.txt') as topo_file:
    for line in topo_file:
        print line,  # The comma to suppress the extra new line char
Posted by: Guest on June-17-2020
0

python iterate through files

import os

directory = os.fsencode(directory_in_str)
    
for file in os.listdir(directory):
     filename = os.fsdecode(file)
     if filename.endswith(".asm") or filename.endswith(".py"): 
         # print(os.path.join(directory, filename))
         continue
     else:
         continue
Posted by: Guest on July-05-2021

Code answers related to "python loop files"

Python Answers by Framework

Browse Popular Code Answers by Language