📜  python 将 ftp 时间戳转换为日期时间 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:05.900000             🧑  作者: Mango

代码示例2
from dateutil import parser

# ...

lines = []
ftp.dir("", lines.append)

latest_time = None
latest_name = None

for line in lines:
    tokens = line.split(maxsplit = 9)
    time_str = tokens[5] + " " + tokens[6] + " " + tokens[7]
    time = parser.parse(time_str)
    if (latest_time is None) or (time > latest_time):
        latest_name = tokens[8]
        latest_time = time

print(latest_name)