获取异常语法错误

时间:2016-02-12 11:36:02

标签: python

我写了一个函数。现在我在try语句中不断收到语法错误。我不知道它是我写的代码还是try语句

功能:

   def connector (links):
      for links in infile:                    
      avenues = links.rstrip()               
      words = []                          
      dct = {}
      cord = []

代码还有更多但是错误一直发生在try语句中,除了什么想法之外呢?

try:
  infile = open("routes.txt", "r")
  links = inf.readlines()
  Connector(links)
  except LookupError as exceptObj:
      print("Error:", str(exceptObj))

1 个答案:

答案 0 :(得分:1)

  • connector应为小写

  • 你缩进了

    try:
      infile = open("routes.txt", "r")
      links = inf.readlines()
      connector(links)
    except LookupError as exceptObj:
      print("Error:", str(exceptObj))