ChinaUnix.net
相关文章推荐:

python 计算曲线

本文转自: http://blog.donews.com/limodou/archive/2005/02/16/278221.aspx Q:如何方便的计算两个时间的差,如两个时间相差几天,几小时等 A:使用datetime模块可以很方便的解决这个问题,举例如下: >>> import datetime >>> d1 = datetime.datetime(2005, 2, 16) >>> d2 = datetime.datetime(2004, 12, 31) >>> (d1 - d2).days 47 上例演示了计算两个日期相差天数的计算。 import datetime starttime = datetime.datetime.now(...

by linxh - Python文档中心 - 2007-01-21 21:49:39 阅读(1578) 回复(0)

相关讨论

google了一把,搜索不到相关资料。 哪位指点一下

by gig2600 - Python - 2006-02-24 21:09:00 阅读(9974) 回复(10)

import sys def main(): k, a, b, a1, b1 = 2L, 4L, 1L, 12L, 4L while 1: # Next approximation p, q, k = k*k, 2L*k+1L, k+1L a, b, a1, b1 = a1, b1, p*a+q*a1, p*b+q*b1 # Print common digits d, d1 = a/b, a1/b1 while d == d1: output(d) a, a1 = 10L*(a%b), 10L*(a1%b1) d, d1 = a/b, a1/b1 def output(d): # Use writ...

by linxh - Python文档中心 - 2007-04-04 21:24:57 阅读(1229) 回复(0)

python刚刚开始感兴趣学习,它适合科学计算吗?

by letwave - Python - 2006-12-27 20:35:45 阅读(2824) 回复(7)

不用说啥了,注释很清楚了~ [color="#008080"]# encoding:gb2312 [color="#008080"]# [color="#008080"]# 本模块利用timeItv模块提供的转换器进行加班时间统计 [color="#008080"]# 输入文件分行列出每天的签到和签退时间 [color="#008080"]# 读入后计算每个有效行的加班时间 [color="#008080"]# 并在最后对超过最低时限的加班时间做出统计 [color="#008080"]# 结果输出到另一文件中 [color="#008080"]# 其中两种方式确定输入文件...

by wibrst - Python文档中心 - 2007-04-29 17:49:41 阅读(1385) 回复(0)

http://bbs3.chinaunix.net/thread-1557627-1-1.html 前2天发的帖子,没人鸟我,通过自己努力解决了,特发出来分享。 我用C/C++ 4 5年了,思想有点转不过来了,代码还是有点C风格,!-_-。 这个用C来写的话很容易,可python没有指针的概念,真是让我一时找不到北了。。。呵呵! 通过查资料,发现有三种方法可以编写这个函数,我实现了其中两种。首先这是通用函数,也就是根本不知道缓冲区里有什么, 所以传递进来的Buffer必须是已...

by dahubaobao - Python - 2009-08-30 09:48:38 阅读(3036) 回复(2)

如何计算,不知道python怎么工作的, # attribute as turning the action into a critical action? if "preserve" in self.attrs and os.path.isfile(final_path): cfile = file(final_path) chash = sha.sha(cfile.read()).hexdigest() 在这的一部分:不理解这个 chash是怎么算出来的,我知道一个文件的sha1值。不理解chash语句是什么意思。查看定义知道python...

by jklyekai - Python文档中心 - 2009-03-27 11:49:51 阅读(2829) 回复(1)

我在安装python的并行计算的pypar的包是总是程序下面的错误,有知道的帮忙解决一下吧! www@www-desktop:~/Desktop/pypar_1.9.3/pypar_1.9.3$ python setup.py install sh: mpicc: not found sh: mpicc: not found sh: mpicc: not found sh: mpicc: not found running install running build running build_py running build_ext building 'pypar.mpiext' extension gcc -pthread -fno-strict-aliasing -DNDEBUG -g -O2 -Wall -W...

by ttkk1024 - Python - 2007-10-19 07:21:55 阅读(3139) 回复(1)

不知道这么写题目会不会让人误会,不过这个题目可以让从搜索引擎上搜索问题的菜鸟们一下找到这篇帖子 这篇是集合了N多大大的方法 上半部是时间加减 下半部是格式化 感谢 xiaoyu9805119 carrison 3227049 给出一个完整的 #!/usr/bin/python #coding:utf-8 import datetime import time format="%Y-%m-%d %H:%M:%S" t1=time.strptime("2008-01-31 00:11:23",format) t2=datetime.datetime(t1[0],t1[1],t1[2],t1[3],t1[4],t1[5],t1...

by ej5800 - Python - 2009-02-16 17:54:03 阅读(16112) 回复(4)

刚开通博客,把今晚写的一个python程序传了上来。 这个类实现了用单步QR分解来计算上Hessenberg矩阵的全部特征值。QR方法是一种计算一般矩阵(中小型矩阵)全部特征值问最有效的方法之一。在很多数值分析的书本上都有该算法的说明,所以在这里不慢慢解释。 其中,在import中代入的几个模块Matrix,Househoulder和Hessenberg,均是用python实现的几个类,在后续几篇博客中,我将慢慢介绍这些类。[color="#...

by taoyuliang - Python文档中心 - 2008-11-15 00:33:31 阅读(2435) 回复(0)

新学乍练 python,遇到一个问题,心血来潮想自己写个程序解决,不料遇到程序中要写一个用于计算阶乘的函数,却怎么也写不出。 逛《啄木鸟》时,无意中看到有人实现了一个,但是限于自身水平不济,竟然看不懂人家的代码,实在不好意思,上来看看这里论坛有没有哪位位老兄能够指点一下,不胜感激。 啄木鸟上的一个源码如下: [code]def P(x, y = None): ''' 求排列数P(x, y),y默认值为x,此时取P(x),即x! ...

by lephon - Python - 2008-08-29 21:40:09 阅读(18821) 回复(17)