2015-04-29 50 views
0

我怎么能摆脱这些红色的下划线?而且我无法在PyCharm中自动完成导入?使用PyCharm自动完成导入

datatype.py:

class DataType: 
    def __init__(self, name): 
     self.name = name 

    def set_value(self, value): 
     self.value = value 

    def get_value(self): 
     return self.value 

这是address.py使用:

enter image description here enter image description here

enter image description here

+0

该模块'datatypes'。除此之外,我不确定是否已经将它导入并在'__init __。py'文件中显示为'Datatype',所以我不能说这会工作*,但基本问题是您错过了“s”。 – Makoto

回答

1

包名是datatypes,您使用from datatype import DataType

它应该是:

# imports module datatype 
    from datatypes import datatype as dt 

    # uses class DataType 
    dt.DataType 

更新:

enter image description here

enter image description here

我添加其他软件包名称test和模块datatype.py下它。 并尝试所有导入的可能性,所有这些都可以导入。 enter image description here

更新: 您应该检查project interpreter,单击>>File >> Settings >> Project Interpreter

+0

我已经更新了我的图片,并且让它更清晰 – Liondancer

+0

@Liondancer检查更新 – haifzhan

+0

仍然红线=/http://postimg.org/image/652sk8w8r/ – Liondancer

2
from .datatype import DataType