나는 아직도 파이썬에 대해 새삼 스럽다. 그래서 나는 분명히 뭔가 빠져있다. Google 스프레드 시트에서 간단한 스프레드 시트를 다운로드하고 파일을 저장 한 다음 Excel에서 열려고합니다. 텍스트 파일을 사용하여 테스트를 수행했을 때 파일을 실행하는 대신 정상적으로 작동했습니다. 그러나 엑셀이 새로 다운로드 한 파일을 열 때 xls와 xlsx를 사용하면 데이터가 손상되었다고 표시됩니다. 이 문제를 어떻게 해결할 수 있습니까?엑셀 스프레드 시트 파이썬 다운로드
import urllib2
print "Downloading..."
myfile = urllib2.urlopen("https://docs.google.com/spreadsheet/pub?key=0AoJYUIVnE85odGZxVHkybGxYRXF1TFpuQXdqZlJwNXc&output=xls")
output = open('C:\\Users\\Lucas\\Desktop\\downloaded.xlsx', 'w')
output.write(myfile.read())
output.close()
print "Done"
import subprocess
subprocess.call(['C:\\Program Files (x86)\\Microsoft Office\\Office14\\EXCEL.exe', 'C:\\Users\\Lucas\\Desktop\\downloaded.xlsx'])
쓰기 위해 파일을 열 때'wb' 플래그를 사용해 보셨습니까? – thegrinner
'w'를 'wb'로 변경하려고 할 수 있습니다. 'b' 플래그는 "이 파일에 이진 코드로 쓰기"를 의미합니다. –
* facepalm * 고맙습니다. – LucasS