gpt4 book ai didi

python - 从邻居导入模块但报告语法错误

转载 作者:太空宇宙 更新时间:2023-11-03 21:30:36 25 4
gpt4 key购买 nike

我正在按照说明学习数据结构,但遇到这样的错误:

文件系统

├── 7.linkedList
│   ├── __init__.py
│   ├── circular_queue.py
│   ├── doubly_linked_base.py
│   ├── favorites_list.py
│   ├── favorites_list_mtf.py
│   ├── insertion_sort_positional.py
│   ├── linkedList.c
│   ├── linked_deque.py
│   ├── linked_queue.py
│   ├── linked_stack.py
│   ├── positional_list.py
│   └── singlyllist.py
├── 8.Tree
│   ├── __init__.py
│   ├── binary_tree.py
│   ├── depth.py
│   ├── euler_tour.py
│   ├── expression_tree.py
│   ├── linked_binary_tree.py
│   ├── traversal_examples.py
│   └── tree.py

8.Tree.tree.py中有代码

from ..7.LinkedList.linked_queue import LinkedQueue
import collections

class Tree:
"""Abstract base class representing a tree structure."""

从7.LinkedList.linked_queue导入函数

In [14]: python /me/Desktop/PubRepo/Algorithms/Algorithms_Wiley/8.Tree/tree.py
File "<ipython-input-14-89fcb9d20232>", line 1
python /me/Desktop/PubRepo/Algorithms/Algorithms_Wiley/8.Tree/tree.py
^
SyntaxError: invalid syntax

它报告无效语法

我尝试了../7.LinkedList.linked_queue,它也不起作用。

我该如何解决这个问题?

最佳答案

除了名称模式之外,您还应该使用 __init__ 提前将存储库作为库

关于python - 从邻居导入模块但报告语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53551423/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com