E:\anaconda\envs\tensorflow\python.exe E:/anaconda1/exer1.py
Traceback (most recent call last):
File "E:/anaconda1/exer1.py", line 1, in <module>
from exer import get_name
File "E:\anaconda1\exer.py", line 1
def get_name(city,popu='',country):
SyntaxError: non-default argument follows default argument
popu=' '放在最后就解决了,一开始放在中间了
def get_name(city,country,popu=''): #country与popu=''不能交换位置
"""城市,国家"""
full = city+', '+str(popu)+'-'+country
return full
from exer import get_name
import unittest
class nametest(unittest.TestCase):
"""测试exer"""
def test_gg(self):
hh = get_name('hangzhou','china','1600')
self.assertEqual(hh,'hangzhou, 1600-china')
unittest.main()