python中的参数传输
我是Python新手,对参数传输有点困惑: 我有两种方法:python中的参数传输,python,parameters,parallel-processing,Python,Parameters,Parallel Processing,我是Python新手,对参数传输有点困惑: 我有两种方法: def convert(self, ipnb, indices = []): with self.fopen(ipnb, u'r') as f: emptyIndicesList = not indices #some code def test_read(self): s = self.convert(self, u'test.ipynb') #some code 我遇到两个
def convert(self, ipnb, indices = []):
with self.fopen(ipnb, u'r') as f:
emptyIndicesList = not indices
#some code
def test_read(self):
s = self.convert(self, u'test.ipynb')
#some code
我遇到两个问题:
self.fopen(ipnb,u'r')作为f
抛出。。。
但是如果我用self.fopen(ipnb,u'r')作为f将更改为
self.fopen(u'test.ipynb',u'r')作为f
它工作正常
emptyIndicesList
是false
,我希望它是true
,因为我认为我使用的是默认参数-empty list
我在参数传输中遗漏了什么?如何解决上述问题谢谢:)您正在将上下文作为第一个参数传递给函数convert 将
s=self.convert(self,u'test.ipynb')
更改为s=self.convert(u'test.ipynb')
,这将解决您的两个问题