我需要调用我在另一个文件中的函数中创建的列表。我试图在下面尝试这个,但我收到了错误cannot import name 'names' from 'backend'。有谁知道如何在不上课的情况下实现这一目标?
import backend
from backend import names
word = names
print (word)
错误信息:
File "C:/Users/user/OneDrive/Desktop/Pokemon/weather.py", line 52, in <module>
from backend import names
builtins.ImportError: cannot import name 'names' from 'backend'
另一个文件的代码是
import const
SEP = ','
def get_pokemon_stats():
"""Reads the data contained in a pokemon data file and parses it into
several data structures.
Args:
None
Returns: a tuple of:
-a dict where:
-each key is a pokemon name (str)
-each value is a tuple of the following stats:
-pokemon name (str)
-species_id (int)
-height (float)
-weight (float)
-type_1 (str)
-type_2 (str)
-url_image (str)
-generation_id (int)
-evolves_from_species_id (str)
-a dict where:
-each key is a pokemon species_id (int)
-each value is the corresponding pokemon name (str)
-a list of all pokemon names (strs)
-a dict where:
-each key is a pokemon type (str). Note that type_1 and type_2
entries are all considered types. There should be no special
treatment for the type NA; it is considered a type as well.
-each value is a list of all pokemon names (strs) that fall into
the corresponding type
"""
name_to_stats = {}
id_to_name = {}
names = []
pokemon_by_type = {}
DATA_FILENAME = 'pokemon.csv'
慕田峪7331174
繁星点点滴滴
相关分类