搜索CHAT_ID的搜索行,然后是相应的行
我在相应的行中保存了一个带有时间密钥的用户数据库。
我需要能够搜索文件以查找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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论