print('参数类型为list时,求和结果为={}'.format(a)),为何这句会报错?
# Enter a code
def func(L):
sum1=0
acc1=1
if(isinstance(L,list)):
for x in L:
sum1=sum1+x
return sum1
if(isinstance(L,tuple)):
for y in L:
acc1=acc1*y
return acc1
L1=[1,3,4,6,2,9]
L2=(1,3)
a=func(L1)
b=func(L2)
print(a)
print(b)
print('参数类型为list时,求和结果为={}'.format(a))
print('参数类型为tuple时,求积结果为={}'.format(b))
有后面两句print会报错,报错结果为:
File "index.py", line 23
SyntaxError: Non-ASCII character '\xe5' in file index.py on line 23, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details