“Loop melalui file python” Kode Jawaban

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 “Loop melalui file python”

Pertanyaan yang mirip dengan “Loop melalui file python”

Lebih banyak jawaban terkait untuk “Loop melalui file python” di Python

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya