I want to change the following code
for directory, dirs, files in os.walk(directory_1):
do_something()
for directory, dirs, files in os.walk(directory_2):
do_something()
to this code:
for directory, dirs, files in os.walk(directory_1) + os.walk(directory_2):
do_something()
I get the error:
unsupported operand type(s) for +: 'generator' and 'generator'
How to join two generators in Python?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…