0
二つの異なる例で
入力ファイルで複数回に同じ関数を呼び出す:私は01と05異なる引数パイソン
機能で一つだけの開始と終了値を持つケース1には、私は
今case1:
inputfile:
one-device:yes
number of device:01-05
first-device:
second-device:
Case2:
one-device:no
number of device:01-05
first-device:01-03
second-device:04-05
持っている:
def func1(self, start, end):
for i, x in enumerate (range(start, end)):
do something
def func10 (self, start, end):
do something
case 2: i have 2 different start and end value that is for first device 01-03 and 04-05.
ケース1私のプログラムの実行の流れ。ケース2のためのような
# if one-device input is yes
func1(arg1, agr2)
func2(arg1, agr2)
func3(arg1, agr2)
func4(arg1, agr2)
func5(arg1, agr2)
func6(arg1, agr2)
func7(arg1, agr2)
func8(arg1)
func9(arg1, agr2,arg3)
func10(agr1,arg2)
func11(arg1, agr2)
func12(arg1, agr2)
func13(arg1)
#if one-device input is no.
#In case2. i need to call two times functions func1 and func10.
私のプログラムの実行の流れは次のとおりです。
# run two times with two diffewnt start and end values as per input in case 2
func1(arg1, agr2)
func1(arg1, agr2)
#flow continues as usal
func2(arg1, agr2)
func3(arg1, agr2)
func4(arg1, agr2)
func5(arg1, agr2)
func6(arg1, agr2)
func7(arg1, agr2)
func8(arg1)
func9(arg1, agr2,arg3)
# run two times with two diffewnt start and end values as per input in case 2
func10(agr1,arg2)
func10(agr1,arg2)
#flow continues as usal
func11(arg1, agr2)
func12(arg1, agr2)
func13(arg1)
Now question is i want to use if else statement to check one-device is yes or no.
if one-device is yes write case 1 flow
if one-device is no write case 1 flow
if no write same flow with using for loop for func1 and func10 to run two times.
If i use this method my code be be lot of duplicate .
I need help here
'func3(user_input)'のように渡すことはできませんか? –
複数の異なる引数を取得するには同じ関数が必要ですか?そして、あなたはどれくらい得ようとしているのか分かりません。 – void
@アデル・アーマド・ノー、私たちはそれを使うことはできません。多くの引数値が変更される可能性があります。 – Bittu