有没有办法在JS中迭代此字符串?

时间:2019-11-28 15:34:22

标签: javascript json python-3.x datetime

我想知道是否可以删除日期和时间。很抱歉,因为这听起来令人困惑。

  import requests
  import json
  import datetime
  stock_ticker= input("Name the stock ticker\n")

  time2= 5

  url =  https://www.alphavantage.co/query?function=TIME_SERIES_INTRADAY&symbol=kmb&interval=5min&apikey=testkey


  response = requests.get(url)

  assert response.status_code == 200

  data =json.loads(response.text)

  this_night= datetime.datetime.now().strftime('%Y-%m-%d')

  minute=int(datetime.datetime.now().strftime('%M'))


  hour=int(datetime.datetime.now().strftime('%H')) - 5

  minute=(round_down(minute,5))

  minute = (f"{minute:02d}")
  if hour < 10 or hour > 16 :

    last_night1=datetime.datetime.now().strftime('%Y-%m-')
    last_night2=int(datetime.datetime.now().strftime('%d') )-1 

    last_night2= (f"{last_night2:02d}")

    last_hour= " 16:00:00"

    last_night_open= last_night1+last_night2+last_hour

    open_share_price = data["Time Series (5min)"][last_night_open]["4. close"]

    print("The stock market closed: the last known price is "+ str(open_share_price))

  x = 9

  while x != 16 and hour != 16:
    try:

      stock_date= this_night + " "

      x = (f"{x:02d}")

      stock_time = str(x) + ":35:00"

      stock_datetime = stock_date + stock_time

      x = int(x)

      **open_share_price = data["Time Series (5min)"][stock_datetime]["1. open"]**

      print(stock_datetime + ": " + str(open_share_price))

      x+= 1

有没有办法将这种粗体更改为JS。

0 个答案:

没有答案