所以我在python2.7中有以下代码。与主.py和一个字符串处理.py包含类
在我的主.py我有
import stringmanipulation
testvalue = "[323232 , 232323]"
testvalue.stringmanipulation.modify()
在我的字符串处理.py我有
class modify (object):
def __init__(self):
extract = self.split('[', 1)[1].split(']')[0]
extract.split(", ")
self.x = extract[0]
self.y = extract[1]
现在我得到的错误是
testvalue.stringmanipulation.modify()
AttributeError: 'str' object has no attribute 'stringmanipulation'
如果我用另一种方法
newvariable = stringmanipulation.modify(testvalue)
这个代码很好用
目前没有回答
相关问题 更多 >
编程相关推荐