Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

python »ñÈ¡±¾»úip

>>> from socket import socket, SOCK_DGRAM, AF_INET
>>> s = socket(AF_INET, SOCK_DGRAM)
>>> s.connect(('google.com', 0))
>>> s.getsockname()
('192.168.1.113', 43711) 
Linux:
import socket
import fcntl
import struct
def get_ip_address(ifname):
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
return socket.inet_ntoa(fcntl.ioctl(
s.fileno(),
0x8915, # SIOCGIFADDR
struct.pack('256s', ifname[:15])
)[20:24])
#get_ip_address('lo')»·»ØµØÖ·
#get_ip_address('eth0')Ö÷»úipµØÖ· 
Windows:
import re,urllib2
from subprocess import Popen, PIPE
print "±¾»úµÄ˽ÍøIPµØַΪ£º" + re.search('\d+\.\d+\.\d+\.\d+',Popen('ipconfig', stdout=PIPE).stdout.read()).group(0)
print "±¾»úµÄ¹«ÍøIPµØַΪ£º" + re.search('\d+\.\d+\.\d+\.\d+',urllib2.urlopen("http://www.whereismyip.com").read()).group(0) 


Ïà¹ØÎĵµ£º

Install Python + Eric IDE


Install Python Eric IDE
1 Download following things
 
1) Python3.1
 
2) PyQt for python 3.1
(http://www.riverbankcomputing.co.uk/software/pyqt/download) I am using
PyQt-Py3.1-gpl-4.7.3-2.exe
 
3) Eric5 IDE
(http://eric-ide.python-projects.org/eric-download.html)
 
2 ......

Python£¬¼òµ¥µÄÁ¦Á¿

Python£¬¼òµ¥µÄÁ¦Á¿
¶¹°êÍø¶Ô»¥ÁªÍøÓû§À´ËµÊÇÖªÃûµÄWeb 2.0ÉçÇø£¬µ«¶Ô¿ª·¢Õ߶øÑÔ£¬¸üÖØÒªµÄÊÇÒ»¸öÓ¦ÓÃPython´òÔìµÄ·Ç³£³É¹¦µÄWeb 2.0Õ¾µã¡£
Pythonµ®ÉúÒÑÓÐ20ÄêµÄÀúÊ·£¬Ä¿Ç°¹úÄÚµÄPython·¢Õ¹×´¿öÈçºÎ£¿ÓëÆäËûÓïÑÔ£¨Æ½Ì¨£©Ïà±È£¬PythonÓÐÄÄЩÏÔ¶øÒ×¼ûµÄÓŵ㣿¶¹°êÓ¦ÓÃPython½øÐÐWeb¿ª·¢ÓÐÄÄЩ³É¹¦¾­Ñé¿ÉÒÔ½è¼ø£¿´ø×ÅÕâЩΠ......

PythonÓïÑÔ¸ÅÀÀ

python
ÓïÑÔ¸ÅÀÀ
 
python
½Å±¾¿ÉÒÔ´¦ÀíÍⲿ´«½øÀ´µÄ²ÎÊý ¼´sys.argv[] 
£¬argv[]
µÄʹÓÃÓëlinux
ÏÂÏàͬ
python
±¾ÉíÊǽâÊÍÓïÑÔ£¬¿ÉÒÔ¶ÔÊäÈëµÄʽ×ÓÇóÖµ¡£python
Ö§³ÖµÄ¶ÔÏóÈçÕûÊý¶¼ÊÇÁ¢¼´Êý£¬´ËÍâËûÖ§³Ö¸´Êý£¬¼°¶ÔËÄÔòÔËËã½âÊÍ¡£
ptyhon
Ö§³Ö×Ö·û´®£¬·ÅÔÚµ¥/
Ë«ÒýºÅÄÚ£¬×Ö·û´®ÊÇÊý×飬¿ÉÒÔͨ¹ý[i: ......

ÓÃPythonÌáÈ¡Îļþ¼ÐϵÄÌض¨À©Õ¹ÃûµÄÎļþ

                ÓÃPythonÌáÈ¡Îļþ¼ÐϵÄÌض¨À©Õ¹ÃûµÄÎļþ
      ²»ÖªµÀʲôʱºò£¬ÍøÏÐ×ÅûÓ㬹ÒÁ˸ölinuxµÄÊÓÆÁ½Ì³Ì£¬ÀïÃæÓкܶà¸öÎļþ¼Ð£¬ÓкܶàÎ޹صÄÎļþ¡£Õâ¶ÔÓÚÏñÎÒûÊÕ²ØÀ¬»øÎļþñ±ºÃµÄÈËÀ´Ëµ£¬¼òÖ±ÊÇ ......

LINUXƽ̨²¿Êðapache+mod_python+django


ǰһƪÎÄÕÂдµÄÔÚAPACHE°²×°MOD_PYTHONµÄ¾­¹ý,Æäʵͦ¼òµ¥,¾ÍÊÇ°æ±¾²»¼æÈݵÄÎÊÌâ.Õâ´ÎÎÒ´ó¸Å˵ϲ¿ÊðDJANGOµÄ¹ý³Ì.
ÏÈÐÞ¸ÄAPACHEÅäÖÃÎļþ,ʹÆä¼ÓÔØmod_pythonÄ£¿é
LoadModule python_module libexec/mod_python.so
ÔËÐÐÃüÁî²é¿´
bin/httpd -M¿ÉÒÔ¿´µ½
 python_module (shared)
Syntax OK
˵Ã÷apacheÒѾ­³É¹¦¼Ó ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ