切割a'的右侧=';用python分隔字符串并存储到列表中

切割a'的右侧=';用python分隔字符串并存储到列表中,python,string,Python,String,初学者的问题 我的文件看起来像--> 如何剪切IP部件并将其存储到列表中以供进一步处理? 请提供帮助。查看str.split函数:)和str.partition()比有限的str.split()更快…感谢您的快速响应 answer = [] with open('path/to/file') as infile: for line in infile: answer.append(line.partition('=')[0].strip()) answer = [] w

初学者的问题
我的文件看起来像-->

如何剪切IP部件并将其存储到列表中以供进一步处理?
请提供帮助。

查看
str.split
函数:)和
str.partition()
比有限的
str.split()
更快…感谢您的快速响应
answer = []
with open('path/to/file') as infile:
    for line in infile:
        answer.append(line.partition('=')[0].strip())
answer = []
with open('path/to/file') as infile:
    for line in infile:
        answer.append(line.partition('=')[0].strip())