本文主要介绍了函数的定义及如何调用,具体如下代码:
代码:
#!/usr/bin/env python
# -*- coding:utf-8 -*-
def p():
while True:
time1=raw_input(‘print input now time:‘)
if time1>‘0‘ and time1<‘12‘:
print ‘Good morning!‘
elif time1>=‘12‘ and time1<‘18‘:
print ‘Good afternoon!‘
elif time1>=‘18‘ and time1<‘24‘:
print ‘Good evening!‘
else:
break
print ‘OVER!‘
p()
运行结果:
时间: 2024-11-07 12:56:32