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 API简介及使用
API简介 Zabbix API开始扮演着越来越重要的角色,尤其是在集成第三方软件和自动化日常任务时.很难想象管理数千台服务器而没有自动化是多么的困难.Zabbix API为批量操作.第三方软件集成以 ...
- Sprite与屏幕之间的关系
锚点这东西挺怀念的,N年前我在做J2ME手游的时候.屏幕整体的坐标是左上角是00点.X轴向右递增,Y轴向下递增.所有的image也是这个原理.只是unity的触摸屏坐标不是左上角,而是左下角. 所以这 ...
- ubuntu 16.04 appstreamcli 问题
http://blog.csdn.net/zhbpd/article/details/77508675
- 更改VS2010的[默认开发语言]
1.菜单-->"工具"-->"导入导出设置".例如以下图: 2.选择"重置全部设置",例如以下图: 3.重置设置,例如以下图: ...
- Ext3.4--TreeGridDemo
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CategoryProper ...
- python 协程(单线程中的异步调用)(转廖雪峰老师python教程)
协程,又称微线程,纤程.英文名Coroutine. 协程的概念很早就提出来了,但直到最近几年才在某些语言(如Lua)中得到广泛应用. 子程序,或者称为函数,在所有语言中都是层级调用,比如A调用B,B在 ...
- android中必备的接口回调用法
1 ,这个方法很常见,本人觉得也很实用,分享下吧 public class DirverDistanceTool { public void getDirverDistance(LatLng star ...
- 浅谈Nutch插件机制(含开发实例)
plugin(插件)为nutch提供了一些功能强大的部件,举个例子,HtmlParser就是使用比较普遍的用来分析nutch抓取的html文件的插件. 为什么nutch要使用这样的plugin系统? ...
- Microchip编译器产品线—MPLAB XC简介
以下为Microchip最新编译器产品线—MPLAB-XC简介 MPLAB-XC:适合所有PIC单片机和项目的编译器解决方案 Microchip最新编译器产品线—MPLAB-XC为项目开发的软件需求提 ...
- java基础---->Comparable和Comparator的使用
Comparable和Comparator都可以实现排序,今天我们就开始两种比较排序接口的学习. Comparable的使用 一.Comparable的文档说明: Lists (and arrays) ...