“Python iterate melalui file” Kode Jawaban

Python Loop melalui file di direktori

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
Proud Polecat

Python iterate melalui file

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
Generic name

Loop melalui 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
Difficult Dragonfly

Jawaban yang mirip dengan “Python iterate melalui file”

Pertanyaan yang mirip dengan “Python iterate melalui file”

Lebih banyak jawaban terkait untuk “Python iterate melalui file” di Python

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya