python bug the C library strftime function.
import time
def date2mktime(date, format_='%Y-%m-%d'):
return int(time.mktime(time.strptime(date, format_)))
d=date2mktime('4000-01-01')
print(d)
C:\Users\Public\py36\python.exe D:/bizPythonDouban/selfPlatformAskAnswerProjeect/b.py
Traceback (most recent call last):
File "D:/bizPythonDouban/selfPlatformAskAnswerProjeect/b.py", line 4, in <module>
d=date2mktime('4000-01-01')
File "D:/bizPythonDouban/selfPlatformAskAnswerProjeect/b.py", line 3, in date2mktime
return int(time.mktime(time.strptime(date, format_)))
OverflowError: mktime argument out of range
C:\Users\sas\.PyCharm2017.2\system\python_stubs\-1603771140\time.py
def strptime(string, format): # real signature unknown; restored from __doc__
"""
strptime(string, format) -> struct_time Parse a string to a time tuple according to a format specification.
See the library reference manual for formatting codes (same as
strftime()). Commonly used format codes: %Y Year with century as a decimal number.
%m Month as a decimal number [01,12].
%d Day of the month as a decimal number [01,31].
%H Hour (24-hour clock) as a decimal number [00,23].
%M Minute as a decimal number [00,59].
%S Second as a decimal number [00,61].
%z Time zone offset from UTC.
%a Locale's abbreviated weekday name.
%A Locale's full weekday name.
%b Locale's abbreviated month name.
%B Locale's full month name.
%c Locale's appropriate date and time representation.
%I Hour (12-hour clock) as a decimal number [01,12].
%p Locale's equivalent of either AM or PM. Other codes may be available on your platform. See documentation for
the C library strftime function.
"""
return struct_time C library function - strftime() http://www.tutorialspoint.com/c_standard_library/c_function_strftime.htm
#include <stdio.h>
#include <time.h> int main () {
time_t rawtime;
struct tm *info;
char buffer[80]; time( &rawtime ); info = localtime( &rawtime ); strftime(buffer,80,"%x - %I:%M%p", info);
printf("Formatted date & time : |%s|\n", buffer ); return(0);
}
python bug the C library strftime function.的更多相关文章
- Python datetime 格式化字符串:strftime()
Python datetime 格式化字符串:strftime() Python 的datetime模块 其实就是date和time 模块的结合, 常见的属性方法都比较常用 比如: datetim ...
- RobotFramework中加载自定义python包中的library(一个py文件中有多个类)
结构如下: appsdk\ appsdk.py(这里面有多个类,包括appsdk,appsdksync等类) __init__.py ... ① 有个appsdk的文件夹(符合python包的定义) ...
- Python 学习笔记(三)Function
python引用变量的顺序: 当前作用域局部变量->外层作用域变量->当前模块中的全局变量->python内置变量 1. Scope: • If a variable is assi ...
- robot framework用python扩展编写自定义library
我的utils.py文件 #!/usr/bin/env python #-*- coding:utf8 -*- __version__ = '0.1' import sys reload(sys) s ...
- 关于Python的函数(Method)与方法(Function)
先上结论: 函数(function)是Python中一个可调用对象(callable), 方法(method)是一种特殊的函数. 一个可调用对象是方法和函数,和这个对象无关,仅和这个对象是否与类或实例 ...
- Python的程序结构[4] -> 函数/Function[1] -> 内建函数
内建函数 / Built-in Function or Method Python中有许多的内建函数(查看内建模块部分),此处将对内建函数进行介绍 内建函数 ord / built-in functi ...
- Python的程序结构[4] -> 函数/Function[2] -> 匿名函数
匿名函数 / Anonymous Function 匿名函数是一种不需要绑定函数名的函数 (i.e. functions that are not bound to a name).匿名函数通过 la ...
- [python]bug和debug
bug:代码中存在的语法或者逻辑问题 debug:自查和解决代码中的问题 (coding五分钟,debug两小时) 一.出现bug原因的四大类型 1.粗心 1)错误案例 上面这个错误就是因为 if语句 ...
- Python使用MySQLdb报Library not loaded: libmysqlclient.18.dylib错误
Library not loaded: libmysqlclient.18.dylib就是找不到这个文件,首先要确定是否有这个文件 可以使用find命令,确认位置后可以使用如下两种方法:1.制作软连接 ...
随机推荐
- zabbix-agent 自动注册
1. 概述 上一篇内容<zabbix自动发现配置>,大概内容是zabbix server去扫描一个网段,把在线的主机添加到Host列表中.我们本篇内容与上篇相反,这次是Active age ...
- ubuntu设置中文拼音输入法
转载 http://www.cnblogs.com/zhj5chengfeng/archive/2013/06/23/3150620.html
- win7 自带计算机(for programmer)
打开win7的Accessories, 看到Calculator, 点击打开计算器. 可以看到32位的2进制代码:
- 怎么输入MathType不等号
MathType是一款比较常用的数学公式编辑器,我们在使用这款软件的时候常常需要输入各种符号.有些新用户对这款软件不是很熟悉,对于一些符号不知道怎么输入,下面我们来给大家介绍介绍MathType不等号 ...
- Faster-RCNN
- 放在github pages上的静态网站怎么取消绑定自定义域名?
使用GitHub Pages搭建的静态网站绑定了自定义域名操作,但是想反悔怎么办? 删除CNAME文件,重新删除仓库,新建后均不行~ 解决办法:清除一下浏览器缓存,或者用别的浏览器打开就好了,因为之前 ...
- 启用lazyload插件,减少图片加载
使用lazyload的js插件,减少图片加载,提高页面加载速度和节省流量.虽然这个头像是第三方服务器来的,不消费博客的流量,但是能节省部分访客的加载时间,也是不错的哦. 用lazyload插件,只是后 ...
- django 错误分类及解决办法汇总
问题1:启动服务器后浏览器无法访问http://localhost:8000,访问被拒绝
- /etc/services
/etc/services文件是记录网络服务名和它们对应使用的端口号及协议,很多的系统程序要使用这个文件.一般情况下,不要修改该文件的内容,否则可能会造成端口冲突 常见的服务如下,各个字段分别表示:s ...
- .Net内存溢出 System.OutOfMemoryException
内存溢出常见的情况和处理方式: http://outofmemory.cn/c/dotNet-outOfMemoryException MSDN中关于processModel的文档 https://m ...