__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. Secant Method (Website)

    Secant Method:  https://www.youtube.com/watch?v=qC9xnsfOd30 Secant Method : http://mathworld.wolfram ...

  2. 关于开发环境 git 重新部署

    apps  开发机器 多次因为升级出现无法登陆 下面就重新部署 流程做笔记 1   备份 根目录下的 那一堆shell 和 Cache/data 下的系统配置 2  shell : su www   ...

  3. [Redux] Navigating with React Router <Link>

    We will learn how to change the address bar using a component from React Router. In Root.js: We need ...

  4. 在LINUX中跟踪函数调用----http://stackoverflow.com/

    http://stackoverflow.com/questions/311840/tool-to-trace-local-function-calls-in-linux I am looking f ...

  5. 提取DLL类库代码

    @SET destFolder=.\bin@XCOPY /I /Y %SYSTEMDRIVE%\WINDOWS\assembly\GAC_MSIL\Microsoft.ReportViewer.Pro ...

  6. java返回参数中几种常见的方法

    1.有参数有返回值 public class text_1 {    1)创建add方法 public int add(int i, int j) {        int res = i + j;  ...

  7. centos mysql 编译安装

    centos mysql 编译安装 1.安装 创建MySQL用户 sudo useradd mysql 下载MySQL的源码包,我们这里使用的时5.5.18 安装依赖 sudo yum -y inst ...

  8. Python之路【第十一篇】:CSS --暂无内容-待更新

    Python之路[第十一篇]:CSS --暂无内容-待更新

  9. 浅谈Android系统的图标设计规范

    http://homepage.yesky.com/89/11620089.shtml 目前移动平台的竞争日益激烈,友好的用户界面可以帮助提高用户体验满意度,图标Icon是用户界面中一个重要的组成部分 ...

  10. android Services注意地方

    使用service前需要在manifest声明: <manifest ... > ... <application ... > <service android:name ...