time_tuple = dateTime.timetuple()typeError:unbound方法dateTime.timetuple()需要一个参数,这是我遇到的错误。如何解决?

发布于 2025-01-31 23:19:18 字数 494 浏览 2 评论 0原文

import requests
import time
import pandas as pd
from datetime import datetime
def datetotimestamp(date):
    time_tuple = datetime.timetuple()
    timestamp = round(time.mktime(time_tuple))
    return timestamp

start = datetotimestamp(datetime(2022,5,18))
end = datetotimestamp(datetime.today)
url = "https://priceapi.moneycontrol.com/techCharts/indianMarket/stock/history?symbol=RELIANCE&resolution=5&from='+str(start)+&to=+str(end)+"
print(url)
import requests
import time
import pandas as pd
from datetime import datetime
def datetotimestamp(date):
    time_tuple = datetime.timetuple()
    timestamp = round(time.mktime(time_tuple))
    return timestamp

start = datetotimestamp(datetime(2022,5,18))
end = datetotimestamp(datetime.today)
url = "https://priceapi.moneycontrol.com/techCharts/indianMarket/stock/history?symbol=RELIANCE&resolution=5&from='+str(start)+&to=+str(end)+"
print(url)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

笑咖 2025-02-07 23:19:18

方法timetuple()是一个实例方法,您无法在datetime类上调用,喜欢

now = datetime.now()
tt = now.timetuple()
timestamp = round(time.mktime(tt))

获取时间戳,只需使用dateTime.timestamp()

now = datetime.now()
print(round(now.timestamp()))

The method timetuple() is an instance method, you can't call is on datetime class, do like

now = datetime.now()
tt = now.timetuple()
timestamp = round(time.mktime(tt))

For getting the timestamp just use datetime.timestamp()

now = datetime.now()
print(round(now.timestamp()))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文