누군가 올바른 방향으로 나를 가리킬 수 있다고 생각하지 않습니까?파이썬이 파일을 여러 목록으로 읽음
텍스트 파일에서 값을 가져 와서이를 깨뜨리고 해당 값과 같은 위치의 목록에 다시 넣는 것이 가장 이상 할 지 궁금합니다.
죄송합니다. 명확하지 않으면 어쩌면 명확 해집니다. 이 파일을 출력하는 코드입니다
#while loop
with open('values', 'a') as o:
o.write("{}, {}, {}, {}, {}, {}, {}\n".format(FirstName[currentRow],Surname[currentRow], AnotherValue[currentRow], numberA, numberB))
currentRow+1
내가 반대를하고 위의 형식의 값을 받아 같은 장소에서 목록으로 다시 넣어 싶습니다. 뭔가 같은 :
#while loop
with open('values', 'r') as o:
o.read("{}, {}, {}, {}, {}, {}, {}\n".format(FirstName[currentRow],Surname[currentRow], AnotherValue[currentRow], numberA, numberB))
currentRow +1
감사
내가 높은 ['cvs'] (http://docs.python.org/2/library/csv.html) 모듈에보고 추천 할 것입니다. 이렇게하면 행을 함께 수동으로 꿰맬 필요없이 쓸 수 있으며 각 행에서 다시 읽으면 목록이됩니다. – thegrinner