Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
349 views
in Technique[技术] by (71.8m points)

javascript - 有没有办法在JS中迭代此字符串?(Is there a way to iterate through this string in JS?)

I was wondering if I could remove the date and time.

(我想知道是否可以删除日期和时间。)

I'm sorry because this sounds confusing.

(很抱歉,因为这听起来令人困惑。)

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

  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

Is there a way I can change this bold to JS.

(有什么办法可以将此粗体更改为JS。)

  ask by Ali Syed translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...