37,721
社区成员
发帖
与我相关
我的任务
分享
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)