[root@localhost python]# ./a1.py
10:30
[root@localhost python]# less a.py
#!/usr/bin/env python
class shijian:
def __init__(self, hr, min):
self.hr = hr
self.min = min
def dayin(self):
return '%d:%d' % (self.hr, self.min)
a = shijian(10, 30)
print a.dayin()
[root@localhost python]# ./a.py
10:30
[root@localhost python]# less a1.py
#!/usr/bin/env python
class shijian:
def __init__(self, hr, min):
self.hr = hr
self.min = min
def __str__(self):
return '%d:%d' % (self.hr, self.min)
a = shijian(10, 30)
print a
[root@localhost python]# ./a1.py
10:30
[root@localhost python]#