![]() |
#2
ipaomi2017-10-18 17:47
|
import sys,pprint, copy
a=[n for n in dir(copy) if not n.startswith('_')]
pprint.pprint(a)
a=[n for n in dir(copy) if not n.startswith('_')]
pprint.pprint(a)
自己改了一下就报错
if not n.startswith('_')
SyntaxError: invalid syntax
修改后报错代码:

import sys,pprint, copy
a=[]
for n in dir(copy):
if not n.startswith('_')
a.append(n)
pprint.pprint(a)
a=[]
for n in dir(copy):
if not n.startswith('_')
a.append(n)
pprint.pprint(a)
感觉两个代码应该是一样的啊,为什么会出错呢?
^