Ò»¡¢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µÄÃæÏò¶ÔÏó»úÖÆÏ£¬Õâȷʵ·Ç³£¼òµ¥¡£ÐèҪעÒâµÄ ......
Java×ÜÓÐËüµÄǧ°ãºÃ´¦Ê¹ÄãÑ¡ÔñËü£¬µ«ÕâÐ©Ëæ±ã··Êé»òÔÚÍøÉϹäһȦ¾ÍÄÜÕÒµ½´ð°¸¡£ÔÚ±¾ÎÄÖУ¬±ÊÕß°Ñ×Ô¼ºÑ§Ï°JavaµÄһЩÇÐÉíÌå»áºÍ¹ý³Ìд³öÀ´£¬¹©³õѧÕß×ö¸ö²Î¿¼¡£ ¡¡¡¡ÎÒÔÚѧϰJavaµÄ¹ý³ÌÖÐÖ÷ÒªÎ§ÈÆÒÔϼ¸¸ö·½ÃæÀ´Ñ§Ï°£º
¡¡¡¡1£®Ê±¿ÌÌáÐÑ×Ô¼ºJavaÊÇÒ»ÖÖOOPÓïÑÔ¹¤¾ß£¬¶ø²»½ö½öÊDZàÂ룬ֻÓÐÕâÑù²ÅÄÜ×ÜÌå°ÑÎÕºÍÔËÓÃJava¡£
¡¡¡¡2£®ÔÚѧϰµÄ¹ý³ÌÖУ¬×îºÃÄܹ»Á˽âJavaµÄµ×²ã»úÖÆ£¬¶ø²»Êǽö½öÍ£ÁôÔÚ±í²ã£¬²»ÊdzÊéÉϵÄÀý×ÓÔËÐгö½á¹û¾Í¿ÉÒÔ¡£Òª×¢Ò⣬¼´±ã¶ÔÒ»¸ö¼òµ¥µÄÀý×ÓÒ²ÒªÓÐÄÍÐÄÈ¥×ÁÄ¥¡¢µ÷ÊÔ¡¢¸Ä¶¯¡£
¡¡¡¡3£®ÔÚѧϰµÄ¹ý³ÌÖÐÒ»¶¨Òª¶¯ÊÖ×ö¡¢Ð´´úÂ룬¶ø²»ÊDZ§Ò»±¾Êé¿´¿´¾ÍÐС£ºÜ¶à¶«Î÷ºÍÌå»á±ØÐë×Ô¼º¶¯ÊÖ²ÅÄÜÕæÕýÊôÓÚ×Ô¼º£¬×îºÃÄܲÎÓëһЩʵ¼ÊµÄÏîÄ¿¡£
¡¡¡¡4£®ÔÚѧµ½Ò»¶¨½×¶Îºó£¬Ä㿪ʼϣÍûÓÃѧ¹ýµÄ¶«Î÷×öЩʲô¡£ÕâʱµÄÄãÓ¦¸Ã¿ªÊ¼Ñ§Ï°Ò»Ð©¸ü¶à¡¢¸ü¸´ÔÓµÄ֪ʶ£¬±ÈÈçJ2EEƽ̨µÄ¹¹½¨¡¢EJBµÄ¿ª·¢µÈ¡£¶ÔÓÚÕâÒ»²¿·Ö£¬ÎÒ½¨Òé×îºÃÕÒÒ»±¾½Ï±¡µÄÊéÏÈÁ˽âÒ»¸ö´ó¸Å£¬ÐÄÀïÓиö×ÜÌåµÄÈÏʶ£¬¶Ô¸ü¶àµÄ¼¼ÊõÊõÓï×ö¸ö³õ²½ÕÆÎÕ¡£ÎÒÈÏΪÕâ¸ö½×¶Î¿´¿´¡¶J2EE¼¼Êõʵ¼ù¡·ºÜ²»´í£¬Ëü¿ÉÒÔÈÃÄãÁ˽âJ2EE°üº¬µÄ¸÷ÖÖ¼¼ÊõºÍ¿ò¼Ü£¬Í¬Ê±ÌṩºÜ¶àʵ¼ÊµÄÀý×ÓÀ´¼ÓÉî¶ÔJ2EEµÄÕûÌåÁ˽⡣
¡¡¡¡Ñ§Ï°JavaµÄÐËȤºÍ¾öÐÄÆðÁ˺ ......
Óû§ÒªÇóͳ¼ÆËùÌṩ¹Ø¼ü×ÖÔÚÍøÂç³öÏÖµÄÐÂÎÅ£¬ÏÂÃæÎªÒ»¸ö²âÊÔµÄmain·½·¨¡£
package com.net;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* @{#} NetTools.java Create on Nov 18, 2009 4:55:57 PM
*
* Copyright (c) 2009 by ThinkIT
* @author Jack He ,jackhexl@gmail.com
* @version 1.0
*/
public class NetTools {
private String url = "";// ÇëÇóµÄURL
private String keyword = "";// ËÑË÷µÄ¹Ø¼ü×Ö
private StringBuffer strBuffer = new StringBuffer("");
private List newsList=new ArrayList();//ÐÂÎÅÊý×é
public static void main(String [] args){
List list=new ArrayList();
NetTools nt=new NetTools();
try {
list=nt.getNews("", new String[]{"»·±£¾Ö"});
for(int i= ......
JAVAÀïµÄPINGÊÇÔÚJDK 1.5ºóÓÃÁËеĺ¯ÊýisreachableȥʵÏÖ,¾ßÌå½éÉÜÈçÏÂ:
InetAddress¶ÔÏóµÄ³£Ó÷½·¨
InetAddressÀàÓкܶà
get
·½·¨£¬ÓÃÀ´»ñÈ¡Ö÷»úÃû£¬Ö÷»úµØÖ·µÈÐÅÏ¢¡£Ö÷ÒªÓУº
byte[] getAddress() ·µ»Ø´Î
InetAddress
¶ÔÏóµÄÔʼ
IP
µØÖ·£¬±£´æÎªÒ»¸ö
byte
Êý×é
String getCanonicalHostName() »ñÈ¡´Ë
IP
µØÖ·µÄ
ÍêÈ«ÏÞ¶¨ÓòÃû
String getHostAddress() »ñÈ¡
IP
µØÖ·µÄ×Ö·û´®£¬·µ»ØÎªÒ»¸ö
String
String getHostName() »ñÈ¡´Ë
IP
µØÖ·µÄÖ÷»úÃû
ÏÂÃæÒ»¸ö¼òµ¥µÄÀý×ÓչʾÕâЩ·½·¨µÄʹÓãº
package
org.dakiler.javanet.chapter1;
import
java.net.InetAddress;
public
class
Example3
{
public
static
void
main(String args[])
throws
Exception
{
InetAddress address=InetAddress.
getByName
(
"www.microsoft.com"
);
System.
out
.println(
"ip: "
+address.getHostAddress());
&n ......
1¡¢length() ×Ö·û´®µÄ³¤¶È
¡¡¡¡Àý£ºchar chars[]={'a','b'.'c'};
¡¡¡¡¡¡¡¡String s=new String(chars);
¡¡¡¡¡¡¡¡int len=s.length();
2¡¢charAt() ½ØÈ¡Ò»¸ö×Ö·û
¡¡¡¡Àý£ºchar ch;
¡¡¡¡¡¡¡¡ch="abc".charAt(1); ·µ»Ø'b'
3¡¢getChars() ½ØÈ¡¶à¸ö×Ö·û
¡¡¡¡void getChars(int sourceStart,int sourceEnd,char target[],int targetStart)
¡¡ ¡¡sourceStartÖ¸¶¨ÁË×Ó´®¿ªÊ¼×Ö·ûµÄϱ꣬sourceEndÖ¸¶¨ÁË×Ó´®½áÊøºóµÄÏÂÒ»¸ö×Ö·ûµÄϱꡣÒò´Ë£¬×Ó´®°üº¬´ÓsourceStartµ½ sourceEnd-1µÄ×Ö·û¡£½ÓÊÕ×Ö·ûµÄÊý×éÓÉtargetÖ¸¶¨£¬targetÖпªÊ¼¸´ÖÆ×Ó´®µÄϱêÖµÊÇtargetStart¡£
¡¡¡¡Àý£ºString s="this is a demo of the getChars method.";
¡¡¡¡¡¡¡¡char buf[]=new char[20];
¡¡¡¡¡¡¡¡s.getChars(10,14,buf,0);
4¡¢getBytes()
¡¡¡¡Ìæ´úgetChars()µÄÒ»ÖÖ·½·¨Êǽ«×Ö·û´æ´¢ÔÚ×Ö½ÚÊý×éÖУ¬¸Ã·½·¨¼´getBytes()¡£
5¡¢toCharArray()
6¡¢equals()ºÍequalsIgnoreCase() ±È½ÏÁ½¸ö×Ö·û´®
7¡¢regionMatches() ÓÃÓڱȽÏÒ»¸ö×Ö·û´®ÖÐÌØ¶¨ÇøÓòÓëÁíÒ»ÌØ¶¨ÇøÓò£¬ËüÓÐÒ»¸öÖØÔØµÄÐÎʽÔÊÐíÔڱȽÏÖкöÂÔ´óСд¡£
¡¡¡¡boolean regionMatches(int startIndex,String str2,int str2StartIndex,int ......
Ò»¡¢±³¾°
×î½üÒ»Äê¶àÀ´,ÔÚInternetÉϳöÏÖµÄÌØ±ðÎüÒýÈ˵Äʼþ¾ÍÊÇJavaÓïÑÔºÍÓÃJava±àдµÄä¯ÀÀÆ÷HotJava¡£
1991Äê,SUNMicroSystem¹«Ë¾µÄJameGosling¡¢BillJoeµÈÈË,ΪÔÚµçÊÓ¡¢¿ØÖÆ¿¾Ãæ°üÏäµÈ¼ÒÓÃÏû·ÑÀàµç×Ó²úÆ·ÉϽøÐн»»¥Ê½²Ù×÷¶ø¿ª·¢ÁËÒ»¸öÃûΪOakµÄÈí¼þ(¼´Ò»ÖÖÏðÊ÷µÄÃû×Ö),µ«µ±Ê±²¢Ã»ÓÐÒýÆðÈËÃǵÄ×¢Òâ,Ö±µ½1994ÄêϰëÄê,InternetµÄѸÃÍ·¢Õ¹,»·ÇòÐÅÏ¢ÍøWWWµÄ¿ìËÙÔö³¤,´Ù½øÁËJavaÓïÑÔÑÐÖÆµÄ½øÕ¹,ʹµÃËüÖð½¥³ÉΪInternetÉÏÊÜ»¶ÓµÄ¿ª·¢Óë±à³ÌÓïÑÔ,Ò»Ð©ÖøÃûµÄ¼ÆËã»ú¹«Ë¾·×·×¹ºÂòÁËJavaÓïÑÔµÄʹÓÃȨ,
ÈçMi-croSoft¡¢IBM¡¢Netscape¡¢Novell¡¢Apple¡¢DEC¡¢SGIµÈ,Òò´Ë,JavaÓïÑÔ±»ÃÀ¹úµÄÖøÃûÔÓÖ¾PCMagazineÆÀΪ1995ÄêÊ®´óÓÅÐã¿Æ¼¼²úÆ·,(¼ÆËã»úÀà¾Í´ËÒ»ÏîÈëÑ¡),ËæÖ®´óÁ¿³öÏÖÁËÓÃJava±àдµÄÈí¼þ²úÆ·,Êܵ½¹¤Òµ½çµÄÖØÊÓÓëºÃÆÀ,ÈÏΪ"JavaÊǰËÊ®Äê´úÒÔÀ´¼ÆËã»ú½çµÄÒ»¼þ´óÊÂ",
΢Èí×ܲñȶû?¸Ç´ÄÔÚÇÄÇĵع۲ìÁËÒ»¶Îʱ¼äºó,²»Î޸п®µØËµ:"JavaÊdz¤Ê±¼äÒÔÀ´×î׿ԽµÄ³ÌÐòÉè¼ÆÓïÑÔ",²¢È·¶¨Î¢ÈíÕû¸öÈí¼þ¿ª·¢µÄÕ½ÂÔ´ÓPCµ¥»úʱ´úÏò×ÅÒÔÍøÂçΪÖÐÐĵļÆËãʱ´ú×ªÒÆ,¶ø¹ºÂòJavaÔòÊÇËûµÄÖØ´óÕ½ÂÔ¾ö²ßµÄʵʩ²¿Êð¡£Òò´Ë,JavaµÄµ®Éú±Ø½«¶ÔÕû¸ö¼ÆËã»ú²úÒµ·¢ÉúÉîÔ¶µÄÓ°Ïì,¶Ô´«Í³µÄ¼ ......