python 3.x-存储和清除变量
发布时间:2022-08-30 19:37:03 375
相关标签: # node.js
目标:
使用yfinance模块刮取Yahoo Finance的代码,并创建标签,说明自上次检查以来股市是上涨还是下跌。
显然,我需要刮两次,然后得到一个值来与另一个值进行比较。我大致知道如何获取值,marketprice vs marketpriceatnextcheck
,但之后如何清除这些值time.sleep
? 我是否将所有内容都放在while循环中?
代码:
import time
import tkinter
from tkinter import *
IXIC = yf.Ticker("^IXIC")
root = Tk()
Text1 = str("The Nasdaq Composite is UP at last check.")
Text2 = str("The Nasdaq Composite is UP at last check.")
V1 = #marketatfirstscrape
V2 = #marketatsecondscrape
def UpDown(self):
if V1 > V2:
#I have this printing to terminal just to check if it works
print(Text1)
else:
print(Text2)
L1 = Label(root, text=UpDown)
L2 = Label(root, text="Have your circumstances changed?", font='times')
L1.grid(row=0, column=0, sticky=W, pady=2)
L2.grid(row=1, column=0, sticky=W, pady=2)
root.mainloop()
while True:
tickers = ['^IXIC']
for ticker in tickers:
ticker_yahoo = yf.Ticker(ticker)
data = ticker_yahoo.history()
last_quote = data['Close'].iloc[-1]
print(last_quote)
time.sleep(900)
特别声明:以上内容(图片及文字)均为互联网收集或者用户上传发布,本站仅提供信息存储服务!如有侵权或有涉及法律问题请联系我们。
举报