There are several pieces of code involved in this one line:
I am considering variable text
is of str
type
(len(text),text.find("Configure"))
This code will return a tuple
of int
, example: (100, 10)
[text.find("Configure")>1]
This code will return a list
of bool
either [True]
or [False]
- Now combining both code blocks above, if index of
"Configure"
is greater than 1 then it will be True
i.e. 1
so element in tuple at index 1
will be taken i.e. 10
, else condition will be False
i.e. 0
so element at index 0
will be taken i.e. 100
(from the example tuple defined above)
(len(text),text.find("Configure"))[text.find("Configure")>1]
- The whole line boils down to:
text[text.find("insert"):100]
or
text[text.find("insert"):10]
and this is basic string slicing in Python
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…