gpt4 book ai didi

python - 在python中搜索单个字符串中的字符串

转载 作者:行者123 更新时间:2023-11-30 23:30:56 27 4
gpt4 key购买 nike

在此代码中,如何在单个语句中检查单个字符串中的多个字符串?

line = '{        AutoLogin = 0;        Captive = 0;        Closed = 0;        Disabled = 0;        LastConnected = "2013-11-27 08:38:10 +0000";        Passpoint = 0;        PossiblyHiddenNetwork = 0;        SPRoaming = 0;        SSID = <534253>;        SSIDString = SBS;        SecurityType = "WPA/WPA2 Personal";        SystemMode = 1;        TemporarilyDisabled = 0;    })'

for token in line.split( ';' ):
if 'RecentNetworks' in token:
start = True
if 'LastConnected' in token:
start = True

最佳答案

试试这个:

for token in line.split(';'):
start = any(s in token for s in ["RecentNetworks", "LastConnected"])

关于python - 在python中搜索单个字符串中的字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20238663/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com