我正在制作一个“灰色”节目,如果我的服务器上台的话,会对其进行检查。 如果是 t,它会tw倒。 之后,它会回头来。
但是,当我执行我的法典时,我发现这一错误:
File "Tweet_bot.py", line 31
textfile = open( /root/Documents/server_check.txt , w )
^
IndentationError: unexpected indent
我的分节守则如下:
try :
response = urlopen( url )
except HTTPError, e:
tweet_text = "Raspberry Pi server is DOWN!"
textfile = open( /root/Documents/server_check.txt , w )
textfile.write("down")
textfile.close()
except URLError, e:
tweet_text = "Raspberry Pi server is DOWN!"
textfile = open( /root/Documents/server_check.txt , w )
textfile.write("down")
textfile.close()
else :
html = response.read()
if textfile = "down":
tweet_text = "Raspberry Pi server is UP!"
textfile = open( /root/Documents/server_check.txt , w )
textfile.write("up")
textfile.close()
if textfile = "up":
tweet_text = ""
pass
if len(tweet_text) <= 140 and tweet_text > 0:
api.update_status(status=tweet_text)
else:
pass