__author__ = 'root'
import datetime
import time
import copy # 12/Dec/2012:23:59:50
# 12/Sep/2012:23:58:50
# 11/Sep/2012:23:59:50
# 19/Sep/2012:23:58:50
def getTime(dtstr):
print dtstr
time = datetime.datetime.strptime(dtstr, '%d/%b/%Y:%H:%M:%S')
return time.strftime('%Y%m%d%H%M%S') lines = open('datefmt.txt').readlines()
lines = [i.strip() for i in lines]
line_copy = copy.copy(lines)
lines = [getTime(line) for line in lines]
lines.sort()
for line in lines:
print line line_copy.sort()
for item in line_copy:
print item
12/Dec/2012:23:59:50
12/Sep/2012:23:58:50
11/Sep/2012:23:59:50
19/Sep/2012:23:58:50
20120911235950
20120912235850
20120919235850
20121212235950
11/Sep/2012:23:59:50
12/Dec/2012:23:59:50
12/Sep/2012:23:58:50
19/Sep/2012:23:58:50

Python 日期格式化 及 schwartzian排序的更多相关文章

  1. Python日期格式化知识

    Python中日期格式化是非常常见的操作,Python 中能用很多方式处理日期和时间,转换日期格式是一个常见的功能.Python 提供了一个 time 和 calendar 模块可以用于格式化日期和时 ...

  2. python日期格式化符号

    python中时间日期格式化符号: %y 两位数的年份表示(00-99) %Y 四位数的年份表示(000-9999) %m 月份(01-12) %d 月内中的一天(0-31) %H 24小时制小时数( ...

  3. python日期格式化与绘图

    画一个量随着时间变化的曲线是经常会遇到的需求,比如画软件用户数的变化曲线.画随时间变化的曲线主要用到的函数是matplotlib.pyplot.plot_date(date,num).由于其第一个变量 ...

  4. python 日期格式化常用标记

    符号   说明             例子    %a  英文星期的简写 Mon  %A  英文星期的完整编写 Monday  %b  英文月份的简写 Jun  %B  英文月份的完整编写 June ...

  5. python中时间日期格式化符号

    python中时间日期格式化符号: import time print(time.strftime('%Y%H%M%S', time.localtime())) 运行结果: 2016092308 %y ...

  6. python time模块介绍(日期格式化 时间戳)

    import time # 1.time.time() 用于获取当前时间的时间戳, ticks = time.time() print(ticks) # 1545617668.8195682 浮点数 ...

  7. Python 日期和时间_python 当前日期时间_python日期格式化

    Python 日期和时间_python 当前日期时间_python日期格式化 Python程序能用很多方式处理日期和时间,转换日期格式是一个常见的功能. Python 提供了一个 time 和 cal ...

  8. 1、Python 日期时间格式化输出

    今天帮朋友写自动化脚本,又需要用格式化日期,又忘记怎么写了,还是写到自己博客里面,方便日后需要的时候看一眼吧.So,临时加一篇 Python 的文章. 1.Python的time模块 import t ...

  9. python 日期生成和时间格式化

    记录下日期时间的转换和生成:1.这个是使用datetime 函数生成往后几天的时间,比如当前日期是2019-07-01 那么控制days=1然后再和当前的时间相加,就能得到明天的日期def time_ ...

随机推荐

  1. 在GDB 中如何记录 instruction-history and function-call-history

    (EDIT: per the first answer below the current "trick" seems to be using an Atom processor. ...

  2. Linux 性能分析工具 nmon for Linux

    http://blog.csdn.net/defonds/article/details/41725929 http://blog.csdn.net/fansy1990/article/details ...

  3. 开始android博客分享

    现在开始写博客,分享android开发中的心得.

  4. LDAP7卸载

    3 Uninstalling Directory Server Enterprise Edition This chapter provides instructions for uninstalli ...

  5. Socket.IO 概述

    为了防止无良网站的爬虫抓取文章,特此标识,转载请注明文章出处.LaplaceDemon/SJQ. http://www.cnblogs.com/shijiaqi1066/p/3826251.html ...

  6. 实现一个线程安全的Queue队列

    使用装饰者模式实现一个线程安全的Queue队列. public class SynchronizedQueue<E> implements Queue<E>, Serializ ...

  7. Python_oldboy_自动化运维之路(一)

    python简介: Python 是一个高层次的结合了解释性.编译性.互动性和面向对象的脚本语言. Python 的设计具有很强的可读性,相比其他语言经常使用英文关键字,其他语言的一些标点符号,它具有 ...

  8. hibernate中有时候复杂删除有时候可以拆分为两个语句

    这个demo是使用原生的sql语句写的,也就是没有调用我在struts中已经写好的公用类common中的增删改查功能,所以要开启事务

  9. Android 通信机制Message、Handler 的用法

    Android中提供了通信机制,Message.Handler 等,Message用于在子线程中传递数据,Handler用于发送数据到主线程中, 下面介绍基于Message.Handler的计时器 i ...

  10. android 数字键盘制作

    //布局相关<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android ...