[root@dba-test hexinyunwei]# python
Python 2.6.6 (r266:84292, Feb 22 2013, 00:00:18)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import time
>>> t = time.localtime(time.time())
>>> ti = '%d' % (t.tm_hour*60+t.tm_min)
>>> print ti
652
>>> if ti <= 655:
... print 'ok'
...
>>> tim = ti = '%d' % 653
>>> tim = '%d' % 653
>>> print tim
653
>>> print ti
653
>>> ti = '%d' % (t.tm_hour*60+t.tm_min)
>>> print ti
652
>>> if ti <= tim:
... print 'ok'
...
ok
>>> if ti >= 655:
... print 'ok'
...
ok
>>> if 3 < 2:
... print 'ok'
...
>>> if 3 < 4:
... print 'ok'
...
ok
>>>
说明python 默认数字是大于字符窜的,最好同类型进行比较
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/23944170/viewspace-2215650/ ,如需转载,请注明出处,否则将追究法律责任。