社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  Python

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

kishore ezio • 6 年前 • 1427 次点击  

我是巨蟒的新手。

我试图写一个程序,它将从.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
 
1427 次点击  
文章 [ 3 ]  |  最新文章 6 年前