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

Python Á·Ï°3 ¶¨ÒåÀ࣬Àà·½·¨£¬ÊµÀý·½·¨

Éè¼ÆÒ»¸öIPÀࣺ
Éè¼Æ1 ÒªÇ󣺳õʼ»¯Ê±¸ø¶¨ipµØÖ·²¢ÅжÏipµØÖ·µÄºÏ·¨ÐÔ
            Àà·½·¨£ºÅжÏipµØÖ·ºÏ·¨ÐÔ
            ʵÀý·½·¨£º½«ipµØÖ·×ª»¯Îª10½øÖƵıíʾÐÎʽ¼°16½øÖƵıíʾÐÎʽ
   ÀýÈ磺192.168.168.8 Ê®½øÖÆÐÎʽΪ3232278536£¬Ê®Áù½øÖÆÐÎʽΪc0a8a808
Éè¼Æ2 ÒªÇó£ºÀ©Õ¹ÒªÇó1ÖÐipÀ࣬ʹÆäʵÀý»¯Ê±Ôö¼Ó×ÓÍøÑÚÂ붨Ò壬²¢ÔÚ³õʼ»¯ÊÇÅжÏ×ÓÍøÑÚÂëµÄºÏ·¨ÐÔ
            ʵÀý·½·¨£º»ñÈ¡ipËùÊô×ÓÍøµÄÍøÂçºÅ£¬¹ã²¥µØÖ·£¬¼°×ÓÍøÄÚip¸öÊý
Éè¼Æ1½âÎö£º
"""Ip address analyzer
Method:
dispIp: Display ip address.
intIp: Get integer of ip address.
hexIp: Get hex of ip address"""
from string import Template

class IpAddress(object):

'Ip address analyzer'

def __init__(self,ip):
'Initialize ip address and netmask'
assert IpAddress.isIp(ip),\
"ip is invalid"
self.ipAddr = ip

def isIp(cls,x):
'Determine if the ip address is valid'
aList = x.split(".")
if len(aList) != 4:
return False
else:
nList=[i for i in aList if (i.isdigit() and 0 <= int(i) <= 255)]
if len(nList) != 4: return False
else: return True
isIp=classmethod(isIp)

def __bin(self,x):
'Convert the decimal into binary,and return 8-bit binary. '
x = int(x)
if x == 0:
return '00000000'
else:
re = ''
while x > 0:
mod = x%2
x = x/2
re = str(mod) + re
differ = 8 - len(re)
re = ''.join(['0' for i in range(differ)]) + re
return re

def dispIp(self):
'Display ip address'
template = Template('IP: ${ipAddr}')
print template.substitute(ipAddr=self.ipAddr)

def intIp(self):
'Return integer of the ip address'
aList = self.ipAddr.split(".")
str2 = ''.join(self.__bin(i) for i in aList)
return str(int(str2, 2))

def hexIp(self):
'Return hex of the ip address'
aList = self.ipAddr.split(".")
retu


Ïà¹ØÎĵµ£º

UltraEdit»·¾³pythonÓï·¨¸ßÁÁÉèÖÃ

ÎÒÒ»Ö±ÔÚÓÃultraedit¿´zope3µÄÔ´´úÂë.Óï·¨¸ßÁÁÉèÖÿɲο¼www.ultraedit.com
UltraEditÊÇÒ»¸öºÜºÃµÄ¹¤¾ß£¬µ«ÊÇĬÈϲ»Ö§³ÖPythonµÄÓï·¨¸ßÁÁ£¬ÏÂÃæÊÇÒ»¸öÏֳɵÄWordFileƬ¶Ï£¬°ÑÕâ¶ÎÎÄ×ÖCopyµ½UltraEditÏÂÃæµÄWORDFIL E.TXTÎļþÖУ¬±£´æºó¾Í¿ÉÒÔ¿´µ½UltraEdit¶ÔPythonÎļþºÍÓï·¨µÄÖ§³ÖÁË^_^£¨×¢Ò⣬°Ñ/L11¸ÄΪÄãµÄWordfileµÄ ......

¶¯Ì¬ÓïÑÔÖ®Î壺PythonÓïÑÔÓëÉè¼ÆÄ£Ê½

 Éè¼ÆÄ£Ê½ÊÇÒ»¸ö³éÏó²ã´Î£¬ÃèÊöÁËÔÚÒ»¸öÌØ¶¨µÄ»·¾³ÖÐÓÃÀ´½â¾öÒ»°ãÉè¼ÆÎÊÌâµÄ¶ÔÏóºÍÀàÖ®¼äµÄ½»»¥¹ØÏµ£¬ÆäÖ÷ҪĿµÄÊdzä·ÖÀûÓÃÓïÑÔµÄÌØÐÔ£¬Éè¼Æ¿É¸´Óõġ¢Äܹ»ÊÊÓ¦ÐèÇó±ä¸üµÄÈí¼þ[9]¡£Éè¼ÆÄ£Ê½ÊÇÒ»ÖÖÉè¼ÆË¼Ï룬ÓïÑÔÊÇʵÏÖ˼ÏëµÄ¹¤¾ß¡£Òò´Ë£¬²»Í¬ÓïÑÔµÄÌØÐÔÓ°ÏìÁËÉè¼ÆÄ£Ê½µÄʵÏÖ£¬ÓÐЩÓïÑÔ¸üÈÝÒ×ʵÏÖÉè¼ÆÄ£Ê½£¬¶øÓÐЩÓïÑÔÔ ......

[Python and or ]Python ÖÐ and or Ö® ÎÒµÄÀí½â

c´úÂë:
int x = a>b?6,6;
ÕâÖÖÓï¾äPythonÖÐÒ²ÓУº
¿ÉÒÔͨ¹ýand or×éºÏÀ´ÊµÏÖ¡£¸öÈËÈÏΪÕâÖÖÓï¾ä¾¡Á¿ÉÙµãºÃ¡£
python°ÑÕâÀàÐ͵ŦÄÜ·¢Ñï¹âÁË´ó¡£µ«ÊÇÓÉÓÚÕâÖÖ×éºÏ±È½ÏÈÆ£¬ËùÒÔÓÐʱºò±È½Ï¾À½á:
±ÈÈç:
5 or 6 and 6  ·µ»Øwhat?
0 or 5  ·µ»Øwhat?
8 and 7  ·µ»Øwhat?
ÓÚÊÇÕûÀíÁËÏ£º
1.pyhon ÖÐÓ ......

Python Á·Ï°2

Éú³ÉÒ»¸öÓÐN¸öÔªËØµÄÓÐËæ»úÕûÊýn×é³ÉµÄÁÐ±í£¬ÆäÖÐNºÍÄêµÄȡֵ·¶Î§ÊÇ£¨1<N<=5£©
ºÍ(0<=n<100)£¬ÏÔʾÕâ¸öÁбíµÄËùÓÐ×Ó¼¯¡£
N¸öÊý×Ö¿ÕÓÐ2en¸ö×Ó¼¯£¬¶ÔÓÚÕâN¸öÊý×ÖÔÚÿ¸ö×Ó¼¯ÖÐÀ´½²ÒªÃ´´æÔÚҪô²»´æÔÚ£¬¿ÉÒÔ²ÉÓÃ×Ó¼¯Ó³ÉäΪ2½øÖƵÄËã·¨¡£
ÀýÈç[a,b]¼¯ºÏµÄ×Ó¼¯£º
¿Õ      ---- &nb ......

pythonϵÄweb¿ª·¢¿ò¼Ü Django,urlÅäÖÃ

urlÅäÖÃ
ÎÒÃÇÔÚpollsÕâ¸öappÏ´´½¨Ò»¸ö
helloworld.py
from django.http import HttpResponse
def index(request):
    return HttpResponse("Hello, Django.")
ÐÞ¸Ä urls.py
from django.conf.urls.defaults import *
# Uncomment the next two lines to enable the admin:
# from django.contrib ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ