【发布时间】:2018-10-09 12:31:54
【问题描述】:
我正在制作一个脚本,用于检查来自谷歌表单的谷歌表格并将结果作为投票的实时供稿可视化返回。我需要弄清楚如何更新值计数,但只有在更新谷歌表时,而不是每 60 秒(或其他时间)检查一次。
这是我目前的设置:
string = ""
while True:
responses = gc.open("QOTD Responses").sheet1
data = pd.DataFrame(responses.get_all_records())
vals = data['Response'].value_counts()
str = "{} currently has {} votes. \n{} currently has {} votes.".format(vals.index[0], vals[0], vals.index[1],
vals[1])
if(str != string):
string = str
print(string)
time.sleep(60) # Updates 1440 times per day
我几乎可以肯定必须有更好的方法来做到这一点,但那会是什么?
谢谢!
【问题讨论】:
标签: python python-3.x gspread