摘要:1importsys23classOutput:4def__init__(self):5self.text=''6defwrite(self,string):7self.text+=string8defwritelines(self,lines):9forlineinlines:10self.write(line)1112classInput:13def__init__(self,input=''):14self.text=input15defread(self,size=None):16ifsize==None:17res,self.text=self.tex
阅读全文
摘要:The ability to halt a process that is being debugged is achieved by settingbreakpoints. By halting the process, you are able to inspect variables, stackarguments, and memory locations without the process changing any of theirvalues before you can record them. Breakpoints are most definitely the mos.
阅读全文
摘要:1>>>fromctypesimport*2>>>c_int()3c_long(0)4>>>c_char_p("helloworld!")5c_char_p('helloworld!')6>>>c_ushort(-5)7c_ushort(65531)8>>>seitz=c_char_p("lovespython")9>>>printseitz10c_char_p('lovespython')11>>>
阅读全文
摘要:1defmore(text,numlines=15):2lines=text.splitlines()3whilelines:4chunk=lines[:numlines]5lines=lines[numlines:]6forlineinchunk:7printline8iflinesandraw_input('More?')notin['y','Y']:9break1011if__name__=='__main__':12importsys13more(open(sys.argv[1]).read(),10)14 1>&g
阅读全文
摘要:1importtornado.ioloop2importtornado.web34classMainHandler(tornado.web.RequestHandler):5defget(self):6self.write("helloworld")78application=tornado.web.Application([(r"/",MainHandler),])910if__name__=="__main__":11application.listen(8888)12tornado.ioloop.IOLoop.instance(
阅读全文
摘要:codeCode highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->1importsys2importstring34CHAR_MAP=dict(zip(string.ascii_lowercase,string.ascii_lowercase[13:26]+5string.ascii_lowercase[0:13]))67defrotate13_letter(letter):8"""9Returnthe13-charrot
阅读全文
摘要:capitalizeCode highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--1'onetWothrEe'.capitalize()2'Onetwothree'3'hellosunshine'.title()4'HelloSunshine'5"abc".upper()6'ABC'7"RAY".lower()8'ray'9importstring10notrans=string.maketrans('','')11de
阅读全文
摘要:maketransCode highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--1intab="aeiou"2outtab="12345"3fromstringimportmaketrans4trantab=maketrans(intab,outtab)5s="thisisastringexample...wow!"6prints.translate(trantab)7th3s3s1str3ng2x1mpl2...w4w![代
阅读全文
摘要:reverseCode highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--1astring="helloray"2revwords=astring.split()3revwords4['hello','ray']5revwords.reverse()6revwords7['ray','hello']8revwords=''.join(revwords)9revwords10'rayhello'11importre
阅读全文
摘要:stringCode highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--1importoperator2pieces=['a','b','c']3largestring=reduce(operator.add,pieces)4largestring5'abc'6faststring=''.join(pieces)7faststring8'abc'9formatstring='%sis%s'%('ray','coding
阅读全文
摘要:alignCode highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--1print'|','hej'.ljust(20),'|','hej'.rjust(20),'|','hej'.center(20),'|'2|hej|hej|hej|3print'hej'.center(2)4hej5print'hej'.center(20,'+')6++++++++hej+++++++++
阅读全文
摘要:isAStringCode highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--1defisAString(anobj):2returnisinstance(anobj,basestring)34a="hello"5isAString(a)6True7b='t'8isAString(b)9True10c=[]11isAString(c)12False13classMyString(str):14pass1516
阅读全文
摘要:setCode highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--1importsets2magic_chars=sets.set('abracadabra')3magic_chars=sets.Set('abracadabra')4poppins_chars=sets.Set('supercalifragilisticexpialidocious')5print''.join(magic_chars&poppins_chars)
阅读全文
摘要:mockCode highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--1>>>frommockerimportMocker2>>>mocker=Mocker()3>>>func=mocker.mock()4>...
阅读全文
摘要:test.txtCode highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--1ThisisasimpledoctestthatcheckssomeofPython'sarithmeticoperations.2>>>2+2344>>&...
阅读全文