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.制作软连接 ...
随机推荐
- Oracle查询优化--单表查询
--查询所有 select * from emp; select * from emp where comm is null; --错误表达 --select * from emp where com ...
- 如何强制关闭Tomcat
用Myeclipse打开后启动Tomcat提示信息为:Address already in use: JVM_Bind:80 ,表示该地址和端口已经被占用显示已经打开了.但是关不掉他...所以只能去关 ...
- kafka学习之-配置详解
# Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreement ...
- 新版SourceTree免帐号登录安装
http://blog.csdn.net/zcbyzcb/article/details/72959720?locationNum=2&fps=1 [ { "$id": & ...
- centos 安装 phalcon
git clone --depth 1 --branch phalcon-v2.0.3 https://github.com/phalcon/cphalcon.git cd cphalcon/ext ...
- cut的用法【转】
cut是一个选取命令,就是将一段数据经过分析,取出我们想要的.一般来说,选取信息通常是针对“行”来进行分析的,并不是整篇信息分析的. (1)其语法格式为:cut [-bn] [file] 或 cut ...
- IOS中数组的使用(NSArray, NSSet, NSDictionary)
一.Foundation framework中用于收集cocoa对象(NSObject对象)的三种集合分别是: NSArray 用于对象有序集合(数组)NSSet 用于对象无序集合(集合) NSDic ...
- PyQt4滑块QSlider、标签QLabel
滑块部件由一个简单的操控杆构成,用户可以通过向前或向后滑动滑块来选择数据.这种选择数据的方式对一些特殊的任务来说比单纯的提供一个数据或使用spin box调整数据大小的方式要自然友好的多.而标签部件则 ...
- Swift-Debug下打印函数名和行数
1.Build Settings ->搜索 Swift compiler -> OTHER_SWIFT_FLAGS = -D DEBUG 2.设置DEBUG函数 配置好后就可以愉快的进行调 ...
- win8.1rtm专业版无法安装net3.5还有iis
win8.1rtm专业版无法安装net3.5还有iis错误代码:0x800F0906 已解决:dism.exe /online /enable-feature /featurename:NetFX3 ...