L配列から、登録された値を取得したいと思いました。
どうして、引数エラーになるのでしょうか?
#実際のコード
python
1""" 2# 標準 3 4r=[] 5l=[1,[2,[[3],4]],5,[6,[[7,8],9]]] 6 7 8def Sample(tes): 9 global r 10 for i in tes: 11 if isinstance(i,list): 12 Sample(i) 13 else: 14 r.append(i) 15 16Sample(l),print(r) 17""" 18 19 20 21class SampleS: 22 def __init__(self): 23 self.r=[] 24 self.l=[1,[2,[[3],4]],5,[6,[[7,8],9]]] 25 26 self.Sample(self.l),print(self.r) 27 28 def Sample(self): 29 for i in self: 30 if isinstance(i,list): 31 self.Sample(i) 32 else: 33 r.append(i) 34 35 36if __name__ == '__main__': 37 SampleS()
#実際のエラー
TypeError: Sample() takes 1 positional argument but 2 were given
TypeError:Sample()は1つの位置引数を取るが、2つが与えられた
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/04/25 08:02