Py学习  »  Python

从给定的.txt文件python读取文件名

kishore ezio • 6 年前 • 1576 次点击  

我是巨蟒的新手。

我试图写一个程序,它将从.txt文件中读取文件。

(这意味着我有一个“filenames.txt”文件,并且该文件中有文件名及其路径) 如何从该.txt文件中读取这些文件名并获取文件的创建日期?

下面是我提出的代码:

import sys, os
import pathlib

# list of filenames with their paths separated by comma 
file_list = []  

# input file name which contains list of files separated by \n
with open ('filenames.txt' , 'r+' ) as f :
    list_file = f.readlines().splitlines()

input_list = file_list + list_file  

def file_check(input_list):
    if input_list is none:
      print ("input_list is null")

print (input_list)

事先谢谢。

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/30405
 
1576 次点击  
文章 [ 3 ]  |  最新文章 6 年前