#!/usr/bin/python from time import ctime,sleep def tsfunc(func): def wrappedFunc(): print '[%s] %s() called' % (ctime().func.__name__) return func() ret
>>> assert 1 == 0Traceback (most recent call last): File "<stdin>", line 1, in <module>AssertionError>>> assert 1 == 1assert断言是一句必须等价于布尔真的判定!1 不等于 0 就会有AssertionErr
#!/usr/bin/python 'if error occur when open a file or readline' try: try: ccfile = open('file9','r') content = ccfile.readlines() except IOError:
#!/usr/bin/python class ShortInputException(Exception): def __init__(self,length,atleast): Exception.__init__(self) self.length = length self.at
server端:#!/usr/bin/python from socket import * from time import ctime HOST='' PORT=21567 BUFSIZ=1024 ADDR=(HOST,PORT) udpSerSock = socket(AF_INET,SOCK_DGRAM) udpSerSock.bind(ADDR) while True:
TCP服务端:#!/usr/bin/python#可以实现client发送字符串给server,server返回该字符串,同时在前面加上时间from socket import * #导入socket模块中所有属性from time import ctime HOST=''
#!/usr/bin/pythonclass Time60(object): def __init__(self,hr,min): self.hr = hr &nbs
Copyright © 2005-2024 51CTO.COM 版权所有 京ICP证060544号