ѧϰJAVAʱ¼äÈÕÆÚÀà×ܽ᡾z¡¿
Ò»¡¢PythonÖеÄÎļþ¹ÜÀí
Îļþ¹ÜÀíÊǺܶàÓ¦ÓóÌÐòµÄ»ù±¾¹¦ÄܺÍÖØÒª×é³É²¿·Ö¡£Python¿ÉÒÔʹÎļþ¹ÜÀí¼«Æä¼òµ¥£¬ÌرðÊǺÍÆäËüÓïÑÔÏà¶Ô±È¡£
ÒÔÏ£¬Peyton McCullough½²½âÁËÎļþ¹ÜÀí»ù´¡¡£
½éÉÜ
ÄãÍæ¹ýµÄÓÎϷʹÓÃÎļþÀ´±£´æ´æµµ£»ÄãϵĶ©µ¥±£´æÔÚÎļþÖУ»ºÜÃ÷ÏÔ£¬ÄãÔçÉÏдµÄ±¨¸æÒ²±£´æÔÚÎļþÖС£
¼¸ºõÒÔÈκÎÓïÑÔ±àдµÄÖÚ¶àÓ¦ÓóÌÐòÖУ¬Îļþ¹ÜÀíÊǺÜÖØÒªµÄÒ»²¿·Ö¡£Pythonµ±È»Ò²²»ÀýÍâ¡£ÔÚÕâƪÎÄÕÂÖУ¬ÎÒÃǽ«Ì½¾¿ÈçºÎʹÓÃһЩģ¿éÀ´²Ù×÷Îļþ¡£ÎÒÃÇ»áÍê³É¶ÁÎļþ£¬Ð´Îļþ£¬Ôö¼ÓÎļþÄÚÈݵIJÙ×÷£¬»¹ÓÐһЩÁíÀàµÄÓ÷¨¡£OK£¬ÈÃÎÒÃÇ¿ªÊ¼°É¡£
¶ÁдÎļþ
×î»ù±¾µÄÎļþ²Ù×÷µ±È»¾ÍÊÇÔÚÎļþÖжÁдÊý¾Ý¡£ÕâÒ²ÊǺÜÈÝÒ×ÕÆÎյġ£ÏÖÔÚ´ò¿ªÒ»¸öÎļþÒÔ½øÐÐд²Ù×÷£º
fileHandle = open ( 'test.txt', 'w' )‘w'ÊÇÖ¸Îļþ½«±»Ð´ÈëÊý¾Ý£¬Óï¾äµÄÆäËü²¿·ÖºÜºÃÀí½â¡£ÏÂÒ»²½¾ÍÊǽ«Êý¾ÝдÈëÎļþ£º
fileHandle.write ( 'This is a test.\nReally, it is.' )Õâ¸öÓï¾ä½«“This is a test.”дÈëÎļþµÄµÚÒ»ÐУ¬“Really, it is.”дÈëÎļþµÄµÚ¶þÐС£×îºó£¬ÎÒÃÇÐèÒª×öÇåÀí¹¤×÷£¬²¢ÇҹرÕÎļþ£º
fileHandle.close()ÕýÈçÄãËù¼û£¬ÔÚPythonµÄÃæÏò¶ÔÏó»úÖÆÏ£¬Õâȷʵ·Ç³£¼òµ¥¡£ÐèҪעÒâµÄÊÇ£¬µ±ÄãÔÙ´ÎʹÓÓw”·½Ê½ÔÚÎļþÖÐдÊý¾Ý£¬ËùÓÐÔÀ´µÄÄÚÈݶ¼»á±»É¾³ý¡£Èç¹ûÏë±£ÁôÔÀ´µÄÄÚÈÝ£¬¿ÉÒÔʹÓÓa”·½Ê½ÔÚÎļþÖнáβ¸½¼ÓÊý¾Ý£º
fileHandle = open ( 'test.txt', 'a' )
fileHandle.write ( '\n\nBottom line.' )
fileHandle.close()È»ºó£¬ÎÒÃǶÁÈ¡test.txt£¬²¢½«ÄÚÈÝÏÔʾ³öÀ´£º
fileHandle = open ( 'test.txt' )
print fileHandle.read()
fileHandle.close()ÒÔÉÏÓï¾ä½«¶ÁÈ¡Õû¸öÎļþ²¢ÏÔʾÆäÖеÄÊý¾Ý¡£ÎÒÃÇÒ²¿ÉÒÔ¶ÁÈ¡ÎļþÖеÄÒ»ÐУº
fileHandle = open ( 'test.txt' )
print fileHandle.readline() # "This is a test."
fileHandle.close()
ͬʱ£¬Ò²¿ÉÒÔ½«ÎļþÄÚÈݱ£´æµ½Ò»¸ölistÖУº
fileHandle = open ( 'test.txt' )
fileList = fileHandle.readlines()
for fileLine in fileList:
print '>>', fileLine
fileHandle.close()PythonÔÚ¶ÁÈ¡Ò»¸öÎļþʱ£¬»á¼ÇסÆäÔÚÎļþÖеÄλÖã¬ÈçÏÂËùʾ£º
fileHandle = open ( 'test.txt' )
garbage = fileHandle.readline()
fileHandle.readline() # "Really, it is."fileHandle.close()¿ÉÒÔ¿´µ½£¬Ö»ÓеڶþÐÐÏÔʾ³öÀ´¡£È»¶ø£¬
Ïà¹ØÎĵµ£º
Ö®ËùÒÔдÕâƪ²©¿Í£¬ÊÇÒòΪǰ¼¸Ìì²ÅÅöµ½ÁËÕâôһ¸öÎÊÌ⣬ÒÔÇ°»¹²»ÖªµÀmysqlÓÐÕâôһ¸öÎÊÌâ¡£
ÎÒÃǵÄϵͳʹÓÃÁËstruts+hibernate£¬Êý¾Ý¿âʹÓõÄÊÇmysql£¬×Ö·û¼¯Í³Ò»Îªutf-8¡£
±¾À´ÒѾÍê³ÉÁË£¬µ«ÊÇϵͳʹÓõÄʱºò£¬·¢ÏÖ²é³öÀ´µÄÈËÃûûÓÐ˳Ðò£¬±¾À´ÒÔΪºÜ¼òµ¥£¬ÔÚ²éѯµÄʱºò£¬Ö¸¶¨°´ÕÕnameÅÅÐò¾Í¿ÉÒÔÁË£¬Æñ֪ʵ¼ÊÒ»×ö²Å·¢Ï ......
javaÖÐnullµÄ¸ÅÄî:javaÖУ¬null±íʾÀà»ò±äÁ¿ÊÇ¿Õ£¬²»´ú±íÈκζÔÏó»òʵÀý£¬¿ÉÒÔ½«null¸³¸øÒýÓÃÀàÐͱäÁ¿£¬µ«²»¿ÉÒÔ½«null¸³¸ø»ù±¾ÀàÐͱäÁ¿¡£Êý¾Ý¿âÖÐNULLµÄ¸ÅÄî:Êý¾Ý¿âÖУ¬null±íʾδÌîд¡¢Î´Öª¡¢²»¿ÉÓõĸÅÄºÍjava²»Í¬µÄÊÇÊý¾Ý¿âÖпÉÒÔ½«null¸³¸øÈκÎÊý¾ÝÀàÐÍ¡£ÕâÑùÒ»À´£¬ÎÒÃÇ´ÓÊý¾Ý¿âÖжÁÈ¡×ֶεÄÖµºó£¬ÔÚjava³ÌÐò ......
³éÏ󻯺ͼ̳йØϵʹ¸ÅÄîºÍ¶¨Òå¿ÉÒÔ¸´Ó㻶à̬ÐÔʹʵÏÖºÍÓ¦ÓÿÉÒÔ¸´Óã»
¿ª±ÕÔÔò£¨Open-Closed Principle OCP£©Ò»¸öÈí¼þʵÌåÓ¦µ±¶ÔÀ©Õ¹¿ª·Å£¬¶ÔÐ޸ķâ±Õ¡£
¶Ô¿É±äÐԵķâ×°ÔÔò£¨Principle of Encapsulation of Variation£© (1)Ò»Öֱ仯ÐÔ²»ºÍÁíÒ»ÖÖ»ìºÏÔÚÒ»Æ𠣨2£©Ò»ÖֿɱäÐÔ²»Ó¦É¢ÂäÔÚ´úÂëµÄºÜ¶àµØ·½¡£
ÀïÊÏ´ú»» ......
Ò»¡¢±³¾°
×î½üÒ»Äê¶àÀ´,ÔÚInternetÉϳöÏÖµÄÌرðÎüÒýÈ˵Äʼþ¾ÍÊÇJavaÓïÑÔºÍÓÃJava±àдµÄä¯ÀÀÆ÷HotJava¡£
1991Äê,SUNMicroSystem¹«Ë¾µÄJameGosling¡¢BillJoeµÈÈË,ΪÔÚµçÊÓ¡¢¿ØÖÆ¿¾Ãæ°üÏäµÈ¼ÒÓÃÏû·ÑÀàµç×Ó²úÆ·ÉϽøÐн»»¥Ê½²Ù×÷¶ø¿ª·¢ÁËÒ»¸öÃûΪOakµÄÈí¼þ(¼´Ò»ÖÖÏðÊ÷µÄÃû×Ö),µ«µ±Ê±²¢Ã»ÓÐÒýÆðÈËÃǵÄ×¢Òâ,Ö±µ½1 ......