先看一个很简单的程序(写在q.py),不报错:
print('hello world')
class Test1():
def __init__(self, config):
self.name=config
def uu(self):
print('我是一个函数',self.name)
a=Test1('sss')
a.uu()
输出是:hello world
我是一个函数 sss
现在我用w.py中写:
import q
q.Test1.uu('www')
这样就会报错:AttributeError: 'str' object has no attribute 'name'
求大神告知这是怎么回事,另外问下,为什么同包下import 会有红色下划线,不胜感谢!!!!
我用的是pycharm