fortune.cgi
资源名称:gateway-1.2.1 [点击查看]
上传用户:gzpyjq
上传日期:2013-01-31
资源大小:1852k
文件大小:0k
源码类别:
手机WAP编程
开发平台:
WINDOWS
- #!/usr/bin/python
- FORTUNE_MAX_TRIES = 10
- SMS_MAX = 160
- import os, string, sys
- def fortune():
- for i in range(FORTUNE_MAX_TRIES):
- f = os.popen("/usr/games/fortune", "r")
- data = f.read()
- f.close()
- data = string.join(string.split(data))
- if len(data) <= SMS_MAX:
- break
- sys.stdout.write("Content-Type: text/plainrnrn")
- sys.stdout.write(data[:SMS_MAX])
- if __name__ == "__main__":
- fortune()