我有一个文本文件,像这样,我想处理它在PythonPython的商店一行行从文本文件列表
info.txt
firstname1
surname1
[email protected]
student1
-------------------
firstname2
surname2
[email protected]
student2
-----------------
我想写一Python代码这iterares并存储在每个指数法示例的每一行:[firstname,surname,[email protected],student]
并忽略"-----"
Python代码
with open('log.txt') as f:
lines = f.read().splitlines()
x = x + 1
for i in lines:
print i
,但我认为这是不对的我AMM很新的蟒蛇可以有一个人请点我在正确的方向 我想输出到我的财产以后,像这样
输出
index 1 :first name: firstname1
Surname: surname1
Email: [email protected]
Student student1
index 2 :first name: firstname2
Surname: surname2
Email: [email protected]
student: student2
请更具体地关于你想要的输出/结果。另外,'x'应该在你的代码中做什么? – timgeb
更新了问题 – Craftx398