[英]How would I make other variables True based on what one variable contains?
How would I make other variables True
based on what one variable contains?如何根据一个变量包含的内容使其他变量为
True
?
Example: If I have variables:示例:如果我有变量:
var1 = False
var2 = False
var3 = False
var4 = False
var5 = False
And I have this next line of command:我有下一行命令:
components = w.find_element_by_id('components-val')
And components
returns as 1, 3, 5
, How do I make variables var1
, var3
, var5
all True
? components
返回为1, 3, 5
,如何使变量var1
、 var3
、 var5
全部为True
?
Same as if I components
return as 1
, 2
, the variables var1
and var2
would be True
就像 I
components
返回1
、 2
一样,变量var1
和var2
将为True
You could save the numbers in a dictionary
and then update it based on your results from compontents
:您可以将数字保存在
dictionary
中,然后根据您的结果更新它compontents
:
true_false = {1: False, 2: False, 3: False, 4: False, 5: False}
components = [1,2,3]
for i in components:
if i in true_false:
true_false[i] = True
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.