搜索CHAT_ID的搜索行,然后是相应的行

发布于 2025-02-12 13:56:31 字数 588 浏览 0 评论 0原文

我在相应的行中保存了一个带有时间密钥的用户数据库。

我需要能够搜索文件以查找ID,然后如果找到了,请检查相应的行以与另一个值进行比较。不确定如何从Python中的文件中读取行。

我的keys.txt文件的示例是

('5492828044', 1659360099957.5688)
('54654', 1657397829695.41)
('875186', 1659385033770.0159)
('654564', 1656879437623.957)
('4564564', 1657397840229.474)

我以前使用的代码刚刚搜索ID,我必须手动添加和删除它们。

keys = open('keys.txt', 'r')
    flag = 0
    index = 0
    for line in keys:
        index += 1
        if str(id) in line:
            flag = 1
            break
    if flag == 0:

不确定如何查找特定ID,然后将下一行与我存储的当前值进行比较。

I am saving a database of users with a time key in the corresponding row.

I need to be able to search the file for the id, then if found check the corresponding row to compare to another value. Not sure how to read rows from a file in python.

example of my keys.txt file is

('5492828044', 1659360099957.5688)
('54654', 1657397829695.41)
('875186', 1659385033770.0159)
('654564', 1656879437623.957)
('4564564', 1657397840229.474)

The code I was previously using just searched for the id and I had to manually add and remove them.

keys = open('keys.txt', 'r')
    flag = 0
    index = 0
    for line in keys:
        index += 1
        if str(id) in line:
            flag = 1
            break
    if flag == 0:

Not sure how to look for a specific id then compare the next row with a current value I have stored.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文