how to loop through files in python code example
Example 1: iterate through all files in directory python
import os
directory = 'the/directory/you/want/to/use'
for filename in os.listdir(directory):
if filename.endswith(".txt"):
continue
else:
continue
Example 2: python loop through files in directory
import os
for filename in os.listdir(directory):
if filename.endswith(".asm") or filename.endswith(".py"):
continue
else:
continue
Example 3: loop through file python
with open('topology_list.txt') as topo_file:
for line in topo_file:
print line,