재부팅 후 원활하게 재개하기 위해 웹 페이지가 변경되었을 때 알려주고 파일의 현재 상태를 파일에 저장하는 Python 스크립트를 작성했습니다. 다음과 같이 코드는 다음과 같습니다타입 오류 파이썬에서 파일에 쓰는 중
import urllib
url="http://example.com"
filepath="/path/to/file.txt"
try:
html=open(filepath,"r").read() # Restores imported code from previous session
except:
html="" # Blanks variable on first run of the script
while True:
imported=urllib.urlopen(url)
if imported!=html:
# Alert me
html=imported
open(filepath,"w").write(html)
# Time delay before next iteration
스크립트를 실행하면 반환
Traceback (most recent call last):
File "April_Fools.py", line 20, in <module>
open(filepath,"w").write(html)
TypeError: expected a character buffer object
------------------
(program exited with code: 1)
Press return to continue
나는 이것이 무엇을 의미하는지 아무 생각도 없어. 필자는 Python에 비교적 익숙하다. 어떤 도움이라도 대단히 감사 할 것입니다.
고맙습니다! 그것은 지금 모두 작동하고 있어요 :) – user118990