if ' └------------' in formula_result: # 判断失败,进行相应处理 row_e = str(row) print(sht_namsss + " " + row_e) all_row_lists.append(row_e) print(all_row_lists)
时间: 2024-02-10 15:26:26 浏览: 33
如果你想将 `row` 存储到一个列表中,可以按照以下方式修改代码:
```python
all_row_lists = [] # 创建一个空列表,用于保存所有的 row
while True:
# 循环判断条件
if ' └------------' in formula_result:
# 判断失败,进行相应处理
row_e = str(row)
print(sht_namsss + " " + row_e)
all_row_lists.append(row_e) # 将 row_e 添加到 all_row_lists 列表中
print(all_row_lists)
# 判断退出条件
if 退出条件: # 请替换为实际的退出条件
break
row += 1 # 更新 row 的值
# 在循环结束后,all_row_lists 将包含所有的 row
print(all_row_lists)
```
在这个示例中,我们创建了一个空列表 `all_row_lists`,并在每次判断失败时将 `row_e`(`row` 的字符串形式)添加到 `all_row_lists` 中。最终,`all_row_lists` 将包含所有的 `row`。请根据实际需求修改和适应代码。
相关问题
if ' └------------' in formula_result: # 判断失败,进行相应处理 print(sht_namsss + " " + str(row)) 报错
根据你提供的代码片段,你可能遇到了一个语法错误或命名错误。根据错误提示,`sht_namsss` 变量未定义。请确保在使用它之前已经定义和赋值。
另外,为了避免潜在的编码错误,建议在使用 `formula_result` 之前确认它已被正确地赋值。确保你的代码中有适当的逻辑来获取和处理 `formula_result` 的值。
以下是一个参考示例,假设 `formula_result` 和 `sht_namsss` 已经定义和赋值,你可以在相应位置进行修改和适配:
```python
if ' └------------' in formula_result:
# 判断失败,进行相应处理
print(sht_namsss + " " + str(row))
```
请根据实际情况检查并修复变量的定义和赋值问题,并确保代码中适当地处理 `formula_result` 的值。
if ' └------------' in formula_result: # 判断失败,进行相应处理 print(sht_namsss + " " + str(row)) 将row存到一个list里面
如果你想将 `row` 存储到一个列表中,你可以在循环外部创建一个空列表,然后在每次判断失败时将 `row` 添加到列表中。以下是示例代码:
```python
row_list = [] # 创建一个空列表,用于保存 row
while True:
# 循环判断条件
if ' └------------' in formula_result:
# 判断失败,进行相应处理
print(sht_namsss + " " + str(row))
row_list.append(str(row)) # 将 str(row) 添加到 row_list
# 判断退出条件
if 退出条件: # 请替换为实际的退出条件
break
row += 1 # 更新 row 的值
# 在循环结束后,row_list 将包含多个 row
print(row_list)
```
在这个示例中,我们在循环外部创建了一个空列表 `row_list`,然后在每次判断失败时将 `str(row)` 添加到 `row_list` 中。最终,`row_list` 将包含多个 `row`。请根据实际需求修改和适应代码。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.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)
![](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)