2004年05月19日 星期三 10:02
There is a class named timedelta in the package datetime. >>> import datetime >>> t1 = datetime.datetime.today() >>> t1 datetime.datetime(2004, 5, 19, 10, 1, 7, 921875) >>> t2 = datetime.datetime.today() >>> t2 datetime.datetime(2004, 5, 19, 10, 1, 18, 391875) >>> t2 - t1 datetime.timedelta(0, 10, 470000) >>> > -----邮件原件----- > 发件人: python-chinese-bounces at lists.python.cn > [mailto:python-chinese-bounces at lists.python.cn] 代表 info at xichen.com > 发送时间: 2004年5月18日 16:10 > 收件人: python-chinese > 主题: [python-chinese] 请问python里面如何求两个时间的差? > > python-chinese,您好! > > 请问python里面如何求两个时间的差?谢谢各位。 > > 致 > 礼! > > > info > info at xichen.com > 2004-05-18
2004年05月19日 星期三 12:23
Qiangning Hong,您好! 谢谢了。 ======= 2004-05-19 10:02:50 您在来信中写道:======= >There is a class named timedelta in the package datetime. > >>>> import datetime >>>> t1 = datetime.datetime.today() >>>> t1 >datetime.datetime(2004, 5, 19, 10, 1, 7, 921875) >>>> t2 = datetime.datetime.today() >>>> t2 >datetime.datetime(2004, 5, 19, 10, 1, 18, 391875) >>>> t2 - t1 >datetime.timedelta(0, 10, 470000) >>>> > >> -----邮件原件----- >> 发件人: python-chinese-bounces at lists.python.cn >> [mailto:python-chinese-bounces at lists.python.cn] 代表 info at xichen.com >> 发送时间: 2004年5月18日 16:10 >> 收件人: python-chinese >> 主题: [python-chinese] 请问python里面如何求两个时间的差? >> >> python-chinese,您好! >> >> 请问python里面如何求两个时间的差?谢谢各位。 >> >> 致 >> 礼! >> >> >> info >> info at xichen.com >> 2004-05-18 >_______________________________________________ >python-chinese list >python-chinese at lists.python.cn >http://python.cn/mailman/listinfo/python-chinese > = = = = = = = = = = = = = = = = = = = = 致 礼! info info at xichen.com 2004-05-19
2004年05月20日 星期四 13:17
python-chinese,您好!
在刘鑫的帮助下,我解决了继承的问题,但是用什么方法才能让test的add方法的值和test1的add1的运算值相加呢?谢谢大家了。
class test:
def __init__(self):
self.a=5
self.b=6
def add(self):
print self.a+self.b
class test1(test):
def __init__(self):
test.__init__(self)
self.c=10
def add1(self):
test.add(self)
p=test1()
print p.a
print p.b
print p.c
int(p.add())+int(p.add1())
致
礼!
info
info at xichen.com
2004-05-20
2004年05月20日 星期四 14:06
Frank Zheng,您好!
按照你的办法
class test:
def __init__(self):
self.a=5
self.b=6
def add(self):
self.a+self.b
class test1(test):
def __init__(self):
test.__init__(self)
self.c=10
def add1(self):
return test.add(self)+self.c
p=test1()
print p.a
print p.b
print p.c
print p.add1()
这样的代码是错误的。
======= 2004-05-20 14:07:01 您在来信中写道:=======
> class test:
> def __init__(self):
> self.a=5
> self.b=6
> def add(self):
> print self.a+self.b
> return self.a+self.b
>
>
> class test1(test):
> def __init__(self):
> test.__init__(self)
> self.c=10
> def add1(self):
> return test.add(self)
>
>python里面函数不用明确声明是否有返回值,有的话在函数定义里面return就行了
>
>----- Original Message -----
>From: <info at xichen.com>
>To: "python-chinese" <python-chinese at lists.python.cn>
>Sent: Thursday, May 20, 2004 1:17 PM
>Subject: [python-chinese] python中继承的问题
>
>
>> python-chinese,您好!
>> 在刘鑫的帮助下,我解决了继承的问题,但是用什么方法才能让test的add方法的值和test1的add1的运算值相加呢?谢谢大家了。
>> class test:
>> def __init__(self):
>> self.a=5
>> self.b=6
>> def add(self):
>> print self.a+self.b
>>
>>
>> class test1(test):
>> def __init__(self):
>> test.__init__(self)
>> self.c=10
>> def add1(self):
>> test.add(self)
>>
>> p=test1()
>> print p.a
>> print p.b
>> print p.c
>> int(p.add())+int(p.add1())
>>
>> 致
>> 礼!
>>
>>
>> info
>> info at xichen.com
>> 2004-05-20
>>
>
>
>--------------------------------------------------------------------------------
>
>
>> _______________________________________________
>> python-chinese list
>> python-chinese at lists.python.cn
>> http://python.cn/mailman/listinfo/python-chinese
>>
>_______________________________________________
>python-chinese list
>python-chinese at lists.python.cn
>http://python.cn/mailman/listinfo/python-chinese
>
= = = = = = = = = = = = = = = = = = = =
致
礼!
info
info at xichen.com
2004-05-20
Zeuux © 2025
京ICP备05028076号