python-3.x - 自动设置 str 列表和设置列表名称
问题描述
我的程序遇到问题,我希望程序使用两列从 txt 中识别字符串,然后将 txt 的字符串放在一个列表中,其中两列中的行名称,我不知道现在如何自动创建列表,但我仍然想制作一个程序,将他在 txt 中识别的所有内容都放在一个列表中。
link = "excelfilett.txt"
file = open(link, "r")
frames_path = []
is_count_frames_path = False
for line in file:
if "[Routing Paths]" in line:
is_count_frames_path = True
if is_count_frames_path== True:
for row in df_frame_array_load["[Name]"]:
if row in line:
a = line[0:4]
a = list(a)
if "[EthernetComNeed]" in line:
break
for row in df_frame_array_load["[Name2]"]:
if row in line:
a = line[0:4]
a = list(a)
if "[EthernetComNeed]" in line:
break
if "[EthernetComConfig]" in line:
break
print(a)
但它只给了我这个:
['F','L','_','9']
虽然我想要类似的东西:
['FL_1','FL_1','FL_2','FL_9']
关于如何做到这一点的任何想法?
解决方案
推荐阅读
- java - 无法执行目标 org.codehaus.mojo:sonar-maven-plugin jar 文件
- java - 而不是多个 if 语句 Java 日期
- c++ - C++ 转换为同一类
- javascript - 如何确定数组中的哪些对象已被用户更改
- c# - Xamarin.Android:带有 MultipartFormDataContent 的 HttpClient 返回 400 错误请求
- android - 让我的 RecyclerView 表现更好
- javascript - 是否可以使用 Break 跳出或跳过爬取功能?
- javascript - 如何将 javascript 的结果显示为 HTML 链接?
- amazon-web-services - 在 Boto3 中检查 AWS S3 写入权限
- apache-spark - 运行 Apache.spark 时出现 NullPointerException