PythonÄ£¿éѧϰ
¡¡¡¡StringIOµÄÐÐΪÓëfile¶ÔÏó·Ç³£Ïñ£¬µ«Ëü²»ÊÇ´ÅÅÌÉÏÎļþ£¬¶øÊÇÒ»¸öÄÚ´æÀïµÄ¡°Îļþ¡±£¬ÎÒÃÇ¿ÉÒÔ½«²Ù×÷´ÅÅÌÎļþÄÇÑùÀ´²Ù×÷StringIO¡£Ò»¸ö¼òµ¥µÄÀý×Ó£¬ÈÃÄã¶ÔStringIOÓÐÒ»¸ö¸ÐÐÔµÄÈÏʶ£º 1 #coding=gbk 2 3 import StringIO, cStringIO, sys 4 5 s = StringIO.StringIO("JGood is a handsome boy") 6 s.write("JGood is a handsome boy \r\n") 7 s.write('okkkkÖйú') 8 s.seek(0) 9 print s.read() 10 11 #×îºó4¸ö×Ö½Ú 12 s.seek(-4, 2) 13 print s.read() 14 15 #---- ½á¹û ---- 16 #JGood is a handsome boy 17 #okkkkÖйú 18 #Öйú ͨ¹ýÀý×Ó£¬ÎÒÃÇ¿´µ½ÁËStringIOµÄÐÐΪ£¬»ù±¾ÓëfileÒ»Ö¡£StringIOÌṩÁËÒ»¸ö·½·¨£¬¿ÉÒÔ·½±ãµÄ»ñÈ¡ÆäÖеÄÊý¾Ý£ºStringIO.getvalue()¡£Èç¹ûʹÓÃread·½·¨»ñÈ¡ÆäÖеÄÊý¾Ý£¬±ØÐëͨ¹ýseekÏÈÉèÖÃ"ÎļþÖ¸Õë"µÄλÖᣠ¡¡¡¡Python±ê׼ģ¿éÖл¹ÌṩÁËÒ»¸öcStringIOÄ£¿é£¬ËüµÄÐÐΪÓëStringIO»ù±¾Ò»Ö£¬µ«ÔËÐÐЧÂÊ·½Ãæ±ÈStringIO¸üºÃ¡£µ«Ê¹ÓÃcStringIOÄ£¿éʱ£¬Óм¸¸ö×¢Òâµã£º 1. cStringIO.StringIO²»ÄÜ×÷Ϊ»ùÀà±»¼Ì³Ð£»2. ´´½¨cStringIO.StringIO¶ÔÏóʱ£¬Èç¹û³õʼ»¯º¯ÊýÌṩÁ˳õʼ»¯Êý¾Ý£¬ÐÂÉú³ÉµÄ¶ÔÏóÊÇÖ»¶ÁµÄ¡£ËùÒÔÏÂÃæµÄ´úÂëÊÇ´íÎóµÄ£ºs = cStringIO.StringIO("JGood\n"); s.write("OOOKKK");
Ïà¹ØÎĵµ£º
2007-07-15
pythonÖеĶàỊ̈߳¨2£©
¹Ø¼ü×Ö: python thread threading
ÎÒÃÇÔÚÉÏÒ»ÕÂÖп´µ½Ê¹ÓÃthreading.Thread.join()¿ÉÒÔ±ÜÃâÖ÷³ÌÐòÔڵȴýÆäËüÏ߳̽áÊøµÄ¹ý³ÌÖеõ½Ê±¼äƬ¡£ÊÂʵÉÏ£¬ÔÚÏ̱߳à³ÌÖо³£»áÓöµ½Ò»¸öÏß³ÌÐèÒªµÈ´ýÁíÒ»¸öÏß³ÌÖеÄÇé¿ö¡£ÔÚÕâÖÖÇé¿öÏ£¬ÐèÒªÖØÉêµÄÊÇ£¬ÎÒÃDz»Ï£ÍûµÈ´ýµÄÏß³ ......
http://hi.baidu.com/guzhilei1986/blog/item/8969b4debe99e150ccbf1ae7.html
º¯Êý ÃèÊö
int(x [,base ]) ......
ÔÚÍøÉÏËѲ»µ½¹ØÓÚ Ascii ºÍ bcd»¥Ïàת»¯µÄÎÄÕ£¬ÓÚÊÇ×Ô¼ºÐ´ÁËÒ»¸ö£¬ºÍ´ó¼Ò·ÖÏíÏ¡£
ûÓп¼Âǵ½Ð§ÂÊ£¬Äܹ»ÓÅ»¯µÄµØ·½Íû´ó¼ÒÌá³ö
"""
AscII×Ö·ûת»»ÎªBCD×Ö·û
"""
def asc2bcd(inAsc, pad_L0_R1 = 0):
#È«²¿×ª»»Îª´óд£¬ÎªºóÃæµÄת»»Ìṩ·½±ã
inAsc = inAsc.upper()
&nb ......
PythonÖеÄeasy_install¹¤¾ßºÜºÃÓã¬ËüµÄ×÷ÓÃÀàËÆÓÚPhpÖеÄpear£¬»òÕßRubyÖеÄgem£¬»òÕßPerlÖеÄcpan¡£
Èç¹ûÏëʹÓÃeasy_install¹¤¾ß£¬¿ÉÒÔÖ±½Ó°²×°ez_setup.py
½Å±¾£¬ÔÙpython ez_setup.py£¨Ö®Ç°ÏÈÒª°²×°python£©£º
°²×°Íêºó£¬×îºÃÈ·±£easy_installËùÔÚĿ¼ÒѾ±»¼Óµ½PATH»·¾³±äÁ¿Àï:
Windows: C:\Python25\Scripts
Li ......
¹ØÓÚC++ºÍPythonÖ®¼ä»¥Ïàµ÷ÓõÄÎÊÌ⣬¿ÉÒÔ²éÕÒµ½ºÜ¶à×ÊÁÏ¡£±¾ÎĽ«Ö÷Òª´Ó½â¾öʵ¼ÊÎÊÌâµÄ½Ç¶È¿´ÈçºÎ¹¹½¨Ò»¸öPythonºÍC++»ìºÏϵͳ¡£
&nbs ......