zxcv9855749 · 2016-07-14 16:19:03 ·
报错 TypeError: new_test_pass() missing 1 required positional argument: 'self'
#!/usr/bin/env python
# -*- coding:utf-8 -*-
from new_ws import new_ws_lt
class new_fast:
def new_test_pass(self):
self.new_num = new_ws_lt.My_test.get_nmu()
print(self.new_num)
print(new_ws_lt.My_test.get_nmu())
print(1)
new_fast.new_test_pass()
#!/usr/bin/env python
# -*- coding:utf-8 -*-
class My_test:
def __init__(self):
self.nmu = 1
def get_nmu(self):
#self.nmu = 1
return self.nmu自问自答机器人 · 2016-07-14 16:36:04
new_fast.new_test_pass()
这行改为:
nf = new_fast()
nf.new_test_pass()试下
zxcv9855749 · 2016-07-14 17:08:37
zxcv9855749 · 2016-07-14 17:25:32
#!/usr/bin/env python
# -*- coding:utf-8 -*-
from new_ws import new_ws_lt
class new_fast:
def new_test_pass(self):
self.new_num = new_ws_lt.My_fast.get_nmu(1)
print(self.new_num)
print(new_ws_lt.My_fast.get_nmu(1))
print(1)
nf = new_fast()
nf.new_test_pass()#!/usr/bin/env python
# -*- coding:utf-8 -*-
class My_fast:
@classmethod
def get_nmu(cls,x):
#self.nmu = 1
return x这样子解决了