代码之家  ›  专栏  ›  技术社区  ›  Macha

为什么在初始化过程中出现python语法错误?

  •  0
  • Macha  · 技术社区  · 15 年前

    此代码:

    class Todo:
        def addto(self, list_name="", text=""):
            """
            Adds an item to the specified list.
            """
            if list_name == "":
                list_name = sys.argv[2]
                text = ''.join(sys.argv[3:]
    
            todo_list = TodoList(getListFilename(list_name))
    

    产生语法错误,小箭头指向 todo_list 在最后一行。

    这个 __init__ 方法 TodoList 这里是:

    def __init__(self, json_location):
        """
        Sets up the list.
        """
        self.json_location = json_location
        self.load()
    

    我对巨蟒有点陌生,所以我不知道我在这里做错了什么。

    1 回复  |  直到 15 年前
        1
  •  11
  •   jbochi    15 年前

    你需要关闭这个)

    text = ''.join(sys.argv[3:]