亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

Chinaunix

標(biāo)題: sockect 應(yīng)用: 輸出靜夜思 ^^ [打印本頁(yè)]

作者: libin1983    時(shí)間: 2008-04-20 00:19
標(biāo)題: sockect 應(yīng)用: 輸出靜夜思 ^^
今天修改了一個(gè) socket 的例子, 如果結(jié)果如下:
               
               
                #!/usr/bin/env python
#coding=GBK
import SocketServer
import time
import random
class SocketServer_test( SocketServer.StreamRequestHandler ):
  def handle( self ):
    poem1 = """\n\r床前明月光\n\r疑似地上霜\n\r舉頭望明月\n\r低頭思故鄉(xiāng)\n\r\t--李白\n\r"""
    poem2 = '\n\rLife is dear, love is dearer. \n\rBoth can be given up for freedom. \n'
    if random.random() > 0.5:
        poemx = poem1
    else:
        poemx = poem2
   
    for a in poemx:
        self.wfile.write('%s'%(a))
        if a in (' ', ',', '.'):
            time.sleep(0.5)
        elif a == '\n':
            time.sleep(1)
        else:
            time.sleep(0.2)
    time.sleep(1)
server = SocketServer.TCPServer( ("", 4321), SocketServer_test )
server.serve_forever()
運(yùn)行結(jié)果如下:


本文來(lái)自ChinaUnix博客,如果查看原文請(qǐng)點(diǎn):http://blog.chinaunix.net/u/10686/showart_569782.html




歡迎光臨 Chinaunix (http://72891.cn/) Powered by Discuz! X3.2