Python ǶÌ׺¯Êý Óë ±äÁ¿×÷ÓÃÓò
a=1
print id(a)
a=2
print id(a)
a=a+1
print id(a)
-------------------------------------------------------------------------------------------------------------------------
t=6
def tt():
global t
t=t+1
print t
print t
tt()
½á¹ûΪ£º
6
7
-------------------------------------------------------------------------------------------------------------------------
t=6
def tt():
t=t+1
print t
print t
tt()
½á¹û£º³ö´í exceptions.UnboundLocalError: local variable 't' referenced before assignment
-------------------------------------------------------------------------------------------------------------------------
def f1(n):
m=n
def f2(i):
print m,i
return f2
a=f1(2)
b=f1(3)
a(1)
b(2)
½á¹û£º
2 1
3 2
-------------------------------------------------------------------------------------------------------------------------
m=999
def f1(n):
m=n
def f2(i):
global m
print m,i
return f2
a=f1(2)
b=f1(3)
a(1)
b(2)
½á¹ûΪ£º
999 1
999 2
Ïà¹ØÎĵµ£º
¶þ½øÖÆÎļþÏÂÔØµØÖ·£º
SinaGetBook
Ч¹ûÈçͼ£º
´úÂ룺
#!/usr/bin/env python
#coding=utf-8
#!/usr/bin/env python
#coding=utf-8
import traceback
import sys
import wx
import re
import urllib
import wx.richtext as rt
import wx.lib.buttonpanel as bp
import Casing
import Debug
def trace_back ......
$ ×Ö·û´®µÄĩβ
^ ×Ö·û´®µÄ¿ªÊ¼
\b ×Ö·ûµÄ±ß½ç
ǰ׺t ×Ö·û´®Öеķ´Ð±Ïߣ¨ËùÓÐ×Ö·û£©²»×ªÒå
? ¿ÉÑ¡µØÆ¥Åä(λÓÚ֮ǰµÄ)µ¥¸ö×Ö·û
() ¸Ä±äÓÅÏȼ¶£¬×÷Ϊһ¸öÕûÌ壬һ¸ö×é
| »òÕß
(A|B) ¾«È·Æ¥ÅäA»òBÖеÄÒ»¸ö
{n,m} Æ¥Å䣨λÓÚ֮ǰµÄ×Ö·û£©nµ½m´Î
VERBOSE ......
client:
import socket, sys
if __name__ == '__main__':
#´¦Àí²ÎÊý
argv = sys.argv
if (len(argv)!=3) or (len(argv)==2 and argv[1]=='/?'):
print '>>>Useage:', argv[0], '<address> < ......
#coding=utf-8
from newtest.wiki.models import WiKi
from django.template import loader, Context
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render_to_response
def index(request, pagename=""):
"""ÏÔʾÕý³£Ò³Ã棬¶ÔÒ³ÃæµÄÎÄ×Ö×öÌØÊâµÄÁ´½Ó´¦Àí"""
......
PythonµÄÃæÏò¶ÔÏóÐÔÖÊ
ÀàºÍ¶ÔÏóÊÇÃæÏò¶ÔÏó±à³ÌµÄÁ½¸öÖ÷Òª·½Ãæ¡£Àà´´½¨Ò»¸öÐÂÀàÐÍ£¬¶ø¶ÔÏóÕâ¸öÀàµÄ ʵÀý ¡£ÕâÀàËÆÓÚÄãÓÐÒ»¸öintÀàÐ͵ıäÁ¿£¬Õâ´æ´¢ÕûÊýµÄ±äÁ¿ÊÇintÀàµÄʵÀý£¨¶ÔÏ󣩡£
ÐèҪעÒâµÄÊÇ£¬ÔÚPythonÖУ¬¼´±ãÊÇÕûÊýÒ²±»×÷Ϊ¶ÔÏó£¨ÊôÓÚintÀࣩ¡£ÕâºÍC++¡¢Java£¨1.5°æÖ®Ç°£©°ÑÕûÊý´¿´â×÷ΪÀàÐÍÊDz»Í¬µÄ¡£Í¨¹ ......