datetime.datetime.now()时间格式转化是碰到的问题
import datetime print datetime.datetime.now() # 2016-03-28 17:16:00.812000 a = ‘2016-03-28 17:16:00.812000’ timeArray = time.strptime(a, '%Y-%m-%d %H:%M:%S.%f') ##注意: %f是microseconds的格式化符号。 print timeArray #time.struct_time(tm_year=2016, tm_mon=3, tm_mday=28, tm_hour=17, tm_min=22, tm_sec=38, tm_wday=0, tm_yday=88, tm_isdst=-1)
a = datetime.datetime.now()
print a ## a变量不指向一个字符串对象,而是指向一个datetime.datetime类型的对象
# 2016-03-28 17:24:52.571000
timeArray = time.strptime(a, '%Y-%m-%d %H:%M:%S.%f') ## 所有这里报错。 time.striptime的第一个参数,应该是字符串对象 Traceback (most recent call last):
File "<console>", line 1, in <module>
File "C:\Python27\lib\_strptime.py", line 467, in _strptime_time
return _strptime(data_string, format)[0]
File "C:\Python27\lib\_strptime.py", line 322, in _strptime
found = format_regex.match(data_string)
TypeError: expected string or buffer
datetime.datetime.now()时间格式转化是碰到的问题的更多相关文章
- DateTime.TryParseExact 万能时间格式转化
本文转载:http://blog.csdn.net/gaofang2009/article/details/6073231 前天同事问C#有没有相关的方法能把"年月日时分秒"这样的 ...
- Sql server 时间格式转化
--.SQL时间格式转化 --日期转换参数 ) --2009-03-15 15:10:02 ),'-',''),' ',''),':','') ) , ) --2009/03/15 ) , ) ) , ...
- time,datetime,时间戳 时间格式转换
总结: time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) datetime.datetime.now().strftime( ...
- win7 蛋疼的时间格式转化
win7系统 获得系统时间为 2015年1月1日 星期5 10:10 数据库中时间格式 是不认识的 转化为 DateTime.Now.ToString("yyyy-MM-dd HH:mm:s ...
- python:时间格式转化
1.获取秒级时间戳与毫秒级时间戳.微秒级时间戳 import time import datetime t = time.time() print (t) #原始时间数据 print (int(t)) ...
- 29-jsp中用js进行时间格式转化
CST可以为如下4个不同的时区的缩写: 美国中部时间:Central Standard Time (USA) UT-6:00 澳大利亚中部时间:Central Standard Time (Austr ...
- oracle 时间格式转化以及计算
--A表中的日期字段 create_date 例如:2017-08-05 转化为2017年8月5日 oracle 在这里的双引号会忽略 select to_char(to_date(tt.c ...
- 时间格式转化 String2datestyle
时间格式转化成string工具类: package cn.javass.util; import java.text.DateFormat; import java.text.SimpleDateFo ...
- Excel中将时间格式转化成时间戳格式
时间戳转成正常日期的公式:C1=(A1+8*3600)/86400+70*365+19其中A1表示当时的1249488000时间戳数值其中C1就是所需的日期格式,C1单元格属性改成日期格式就可以了.正 ...
随机推荐
- HTTP协议(一):介绍
HTTP协议(一):介绍 RFC 2616定义了今天普遍使用的一个版本——HTTP 1.1.HTTP协议(HyperText Transfer Protocol,超文本传输协议)是一种详细规定了浏 ...
- centos 中输入ifconfig 只有lo 没有eth0
问题描述:linux中输入ifconfig命令,只有lo,没有eth0 解决方法: 1.进入/etc/sysconfig/network-scripts 目录,发现有ifcfg-eth0,即网卡(驱动 ...
- (Forward)5 Public Speaking Tips That'll Prepare You for Any Interview
Landing a job interview is incredibly exciting –- and often terrifying. But fear not. There are clev ...
- 此请求的URL的长度超过配置的maxUrlLength值
aps.net 网站的url长度默认限制为260个字符. 修改web.config即可 <system.web> <httpRuntime maxUrlLength=" ...
- Nodejs 8.0 踩坑经验汇总
.Linq:Linq to sql 类 高度集成化的数据库访问技术 使用Linq是应该注意的问题: 1.创建Linq连接后生成的dbml文件不要变动,生成的表不要碰,拖动表也会造成数据库连接发生变动, ...
- bash的常用功能呢
一.tab键可以自动补齐命令 二.命令历史 1.history 查看之前敲过的所有命令 2.!历史命令编号 调用历史的某一个命令 三.命令别名 1.设置别名 alias 别名=‘命令’ 2.移除 ...
- 基于bootstrap的内容折叠功能
加入js及css支持: <link rel="stylesheet" href="css/bootstrap.min.css"/> <scri ...
- thinkphp引入头文件
<include File="Public:regheader" />
- Safari无痕模式下,storage被禁用问题
前言 Safari开启无痕模式后,localStorage和sessionStorage为空,对其进行set操作也会报错,也就是说这种情况下,storage是被禁止使用了.接下来说一下解决方法. 解决 ...
- HTML5 : 文件上传下载
网站建设中,文件上传与下载在所难免,HTML5中提供的API在前端有着丰富的应用,完美的解决了各个浏览器的兼容性问题,所以赶紧get吧! FileList 对象和 file 对象 HTML 中的 in ...