È磺
def aa(i):
print i
a=[1,2,3]
b=2
c=3
ÄÜʶ±ð³öÆðʼλdef aa(i):
ºÍ½áÊøλ" a=[1,2,3]"£¿
ÏñPython¶ÔÓï·¨ÕâôҪÇóÑϸñµÄÎÒ¾õµÃ¾Í²»ÒªÓÃÕýÔòÁË£¬Ð§Âʲ»¸ß¡£Ö±½ÓÓÃÅжϾͿÉÒÔÁË£¬ÎÒдÁ˸öʶ±ð¶¥¼¶º¯ÊýµÄ£¬Å×שÒýÓñ£º
Python code:
s = r'''
def aa(i):
print i
a=[1,2,3]
b=2
c=3
def a():
print\
'w'
'''
def findFunc(s):
result = []
begin = False
def show(x): print '\n***Function***:\n', '\n'.join(x)
ss = s.split('\n')
for i,row in enumerate(ss):
if len(row)==0: continue
if begin:
if row.startswith(' '):
result.append(row)
elif ss[i-1].endswith('\\'):
result.append(row)
else:
show(result)
begin = False
result = []
if row.startswith('def '):
begin = True
result.append(row)
show(result)
findFunc(s)
ÎÒ¾õµÃÓ¦¸ÃÓÃast ²ÅÄÜ°ÑËûÕýÈ·½âÊͳöÀ´
e.g.,
import ast
class V(ast.NodeVisitor):
def visit_FunctionDef(self, node):
print 'def %s' % (node.name)
s='''
def aa(i):
print i
a = [ 1, 2, 3]
b = 2
c = 3
'''
t = ast.parse(s)
V().visit(t)
Ïà¹ØÎÊ´ð£º
´ó¼ÒºÃ£¬ÎÒÊÇÒ»¸öÐÂÊÖ£¬¸Õ¿ªÊ¼Ñ§python£¬µ«ÊǸտªÊ¼µÄhelloworld¶¼Ã»·¨´òÓ¡£¬ÈÃÎÒºÜÎÞÄΡ£
ÎÒµÄpython°²×°Â·¾¶Îªf:\python31¡£ÔÚpathÖÐÒ²ÉèÖöÔÁË£¬ÔÚwindowsÏÂÔËÐÐÊÇÕâÑùÏÔʾµÄ£¬Ï£Íû¸÷λǰ±²Ö¸µãһϡ£Ð»Ð»
Pyth ......
ѧϰpythonµÄ7±¾Êé
°üÀ¨6±¾chm£¬Ò»±¾pdf×ÊÁÏ
¶ÔѧϰpythonÓкܴóµÄ°ïÖú
http://download.csdn.net/source/619791
¾«ÐÄËѼ¯£¬²»Òª»ý·Ö£¬ÄóöÀ´·ÖÏí
лл¥Ö÷£¬ÐÁ¿àÁË~
lz ×îºÃ°ÑÊéÃûºÍ¼òµ¥½éÉܼÓÉ ......
ÎÒÔÚÅú´¦ÀíÖе÷ÓÃpython½Å±¾
ÈçÏ£º
call %pyscript%\StaticResult.py -s D:\DailySDV\Bts8.1\TestLog\TestResult.xml -d %CiRoot_WndPath%\cruisecontrol\userData\groups\group01\projects\%ProjectName%\%GtrRl ......
python
content=str.find('ok') && content=str.find('not ok')
ÕâÑù±íʾ ÔÚÄÚÈÝÖÐÕÒµ½ ok »òÕß ÕÒµ½ not ok ¶ÔÂð£¿
²¢ÁÐÌõ¼þÓà and ¶ø²»ÊÇ&&
......
Python code:
class A:
def __init__(self):
self.B_Handle = B_Handle
self.VA = "A_init"
print "Class A init"
def __getattr__(self, name):
......