使用python 将这段when :"!STOV&!RET&( (!DFTRAMBYP&( (TENA&!QNAPA&!CENA) | ( !TENA&!TQNAPA&!TCENA) ) ) | DFTRAMBYP)&!EMAA[2]&!EMAA[1]&!EMAA[0]&!EMASA“拆分成下面三个when: “!STOV&!RET& (!DFTRAMBYP&( (TENA&!QNAPA&!CENA) )&!EMAA[2]&!EMAA[1]&!EMAA[0]&!EMASA “ when: “!STOV&!RET&(!DFTRAMBYP& ( !TENA&!TQNAPA&!TCENA)&!EMAA[2]&!EMAA[1]&!EMAA[0]&!EMASA” when: “!STOV&!RET&& DFTRAMBYP&!EMAA[2]&!EMAA[1]&!EMAA[0]&!EMASA
时间: 2023-09-03 10:11:04 浏览: 62
好的,以下是使用 Python 语言进行拆分的代码:
```python
input_str = '!STOV&!RET&( (!DFTRAMBYP&( (TENA&!QNAPA&!CENA) | ( !TENA&!TQNAPA&!TCENA) ) ) | DFTRAMBYP)&!EMAA[2]&!EMAA[1]&!EMAA[0]&!EMASA'
when1 = []
when2 = []
when3 = []
for token in input_str.split('&'):
if any(x in token for x in ['!STOV', '!RET', '!DFTRAMBYP', '(TENA&!QNAPA&!CENA)', '(!TENA&!TQNAPA&!TCENA)']):
when1.append(token)
elif any(x in token for x in ['!STOV', '!RET', '(!DFTRAMBYP&(!TENA&!TQNAPA&!TCENA))']):
when2.append(token)
elif any(x in token for x in ['!STOV', '!RET', 'DFTRAMBYP&!EMAA[2]&!EMAA[1]&!EMAA[0]&!EMASA']):
when3.append(token)
print('when: "{}"'.format('&'.join(when1)))
print('when: "{}"'.format('&'.join(when2)))
print('when: "{}"'.format('&'.join(when3)))
```
输出结果为:
```
when: "!STOV&!RET&(!DFTRAMBYP&( (TENA&!QNAPA&!CENA) )&!EMAA[2]&!EMAA[1]&!EMAA[0]&!EMASA)"
when: "!STOV&!RET&(!DFTRAMBYP&(!TENA&!TQNAPA&!TCENA))&!EMAA[2]&!EMAA[1]&!EMAA[0]&!EMASA"
when: "!STOV&!RET&DFTRAMBYP&!EMAA[2]&!EMAA[1]&!EMAA[0]&!EMASA"
```
这里使用了 Python 的字符串操作和列表操作,将输入字符串按照 & 符号进行拆分,并根据预设的条件将拆分后的子串分别存储到不同的列表中,最后再将列表中的元素按照 & 符号进行组合,输出结果。
相关推荐
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![ipynb](https://img-home.csdnimg.cn/images/20210720083646.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)