저는 프로그래밍에 익숙하지 않습니다. 트위터 ID 목록을 반복하고 타임 라인을 검색하여 json 아카이브에 저장하는 스크립트를 만들었습니다. 그러나 매번 마지막 타임 라인이 걸리고 파일을 덮어 쓰고 마지막 타임 라인 만 유지한다고 생각합니다.
이것은 루프의 내 코드입니다.
idfile = open('ids_part1.txt', 'r+')
for id in idfile:
if id:
id = id.strip()
try:
result = ret_timeline(user_id=id)
if result:
result_file = open('result1.json', 'w+')
for st in result:
result_file.write(json.dumps(st._json, indent=4, sort_keys=True))
result_file.close()
저를 도와 주 시겠어요? 대단히 감사합니다!
추가 모드에서 파일을 열어야하며 괜찮습니다.
result_file = open('result1.json', 'a')
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다