for i in aeb_bag_name: if i in record_path: pattern = r'\d{14}' result = re.search(pattern, i) print(result.group()) date_obj = datetime.datetime.strptime(result.group(), "%Y%m%d%H%M%S") hour = date_obj.hour minute = date_obj.minute second = date_obj.second a = f"{hour}:{minute}:{second}" print(a) with open('files.txt', 'r') as f: for line in f: if a in line: print(line)修改代码second值可能会大于或者小于文本中的值,上下浮动不超过2

时间: 2024-02-10 15:24:44 浏览: 28
如果你想修改代码以处理秒值的浮动范围,可以使用以下方法: ```python import datetime # 假设你已经定义了 aeb_bag_name、record_path 和 files.txt for i in aeb_bag_name: if i in record_path: pattern = r'\d{14}' result = re.search(pattern, i) timestamp_str = result.group() # 将时间戳字符串转换为 datetime 对象 date_obj = datetime.datetime.strptime(timestamp_str, "%Y%m%d%H%M%S") hour = date_obj.hour minute = date_obj.minute second = date_obj.second # 定义浮动范围 floating_range = 2 # 在这里设置你的浮动范围 # 遍历文件行并查找匹配的时间戳 with open('files.txt', 'r') as f: for line in f: if f"{hour}:{minute}" in line: # 只比较小时和分钟 time_parts = line.strip().split(':') file_second = int(time_parts[2]) if abs(second - file_second) <= floating_range: print(line) ``` 在上述代码中,我们首先定义了浮动范围,即 `floating_range`,表示允许秒值与文件中的秒值相差的最大绝对值。在遍历文件行时,我们只比较小时和分钟部分,然后提取出文件行中的秒值,并检查它与时间戳中的秒值是否在浮动范围内。如果是,则打印该行。 请注意,上述代码假设文件中的时间格式为 `HH:MM:SS`,例如 `17:32:29`。如果你的文件行表示时间的方式不同,请相应地调整代码。

相关推荐

DALVIK THREADS (136): "Signal Catcher" daemon prio=5 tid=7 Runnable | group="system" sCount=0 dsCount=0 flags=0 obj=0x12c401a0 self=0xa85d4a00 | sysTid=944 nice=0 cgrp=default sched=0/0 handle=0x7dba8230 | state=R schedstat=( 54080844 151346 9 ) utm=2 stm=3 core=1 HZ=100 | stack=0x7daad000-0x7daaf000 stackSize=1008KB | held mutexes= "mutator lock"(shared held) native: #00 pc 00303613 /apex/com.android.runtime/lib/libart.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, int, BacktraceMap*, char const*, art::ArtMethod*, void*, bool)+78) native: #01 pc 003aeb4b /apex/com.android.runtime/lib/libart.so (art::Thread::DumpStack(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, bool, BacktraceMap*, bool) const+358) native: #02 pc 003ab193 /apex/com.android.runtime/lib/libart.so (art::Thread::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, bool, BacktraceMap*, bool) const+34) native: #03 pc 003c3ecf /apex/com.android.runtime/lib/libart.so (art::DumpCheckpoint::Run(art::Thread*)+606) native: #04 pc 003be9bd /apex/com.android.runtime/lib/libart.so (art::ThreadList::RunCheckpoint(art::Closure*, art::Closure*)+356) native: #05 pc 003be079 /apex/com.android.runtime/lib/libart.so (art::ThreadList::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, bool)+1444) native: #06 pc 003bd9ef /apex/com.android.runtime/lib/libart.so (art::ThreadList::DumpForSigQuit(std::__1::basic_ostream<char, std::__1::char_traits<char>>&)+678) native: #07 pc 003876f3 /apex/com.android.runtime/lib/libart.so (art::Runtime::DumpForSigQuit(std::__1::basic_ostream<char, std::__1::char_traits<char>>&)+130) native: #08 pc 003968a7 /apex/com.android.runtime/lib/libart.so (art::SignalCatcher::HandleSigQuit()+1026) native: #09 pc 00395cff /apex/com.android.runtime/lib/libart.so (art::SignalCatcher::Run(void*)+246) native: #10 pc 000a6077 /apex/com.android.runtime/lib/bionic/libc.so (__pthread_start(void*)+20) native: #11 pc 00060131 /apex/com.android.runtime/lib/bionic/libc.so (__start_thread+30) (no managed stack frames)

.login { display: flex; justify-content: center; align-items: center; height: 100%; background-color: rgba(184, 153, 90, 0.62); } .login-box { width: 1000px; height: 474.38px; border-radius: 8px; display: flex; } .login-box img { width: 60%; height: auto; } .title { margin: 0px auto 30px auto; text-align: center; color: #707070; } .login-form { background: #fdfdfd; width: 40%; border-radius: 0px 8px 8px 0px; display: flex; justify-content: center; align-items: center; } .login-form .el-form { width: 214px; height: 307px; } .login-form .el-form-item { margin-bottom: 30px; } .login-form .el-form-item.is-error .el-input__inner { border: 0 !important; border-bottom: 1px solid #fd7065 !important; background: #fff !important; } .login-form .input-icon { height: 32px; width: 18px; margin-left: -2px; } .login-form .el-input__inner { border: 0; border-bottom: 1px solid #e9e9e8; border-radius: 0; font-size: 14px; font-weight: 400; color: #333333; height: 32px; line-height: 32px; } .login-form .el-input__prefix { left: 0; } .login-form .el-input--prefix .el-input__inner { padding-left: 26px; } .login-form .el-input__inner::placeholder { color: #aeb5c4; } .login-form .el-form-item--medium .el-form-item__content { line-height: 32px; } .login-form .el-input--medium .el-input__icon { line-height: 32px; } .login-btn { border-radius: 17px; padding: 11px 20px !important; margin-top: 10px; font-weight: 500; font-size: 14px; border: 0; background-color: #ffc200; } .login-btn:hover, .login-btn:focus { /* background: #FFC200; */ /* color: #ffffff; */ } .login-form-title { height: 36px; display: flex; justify-content: center; align-items: center; margin-bottom: 40px; } .login-form-title .title-label { font-weight: 500; font-size: 20px; color: #333333; margin-left: 10px; }

ArgumentNullException: Value cannot be null. Parameter name: _unity_self UnityEditor.SerializedObject.FindProperty (System.String propertyPath) (at <505360e321ae48e3804e227a34262e1e>:0) UnityEditor.UIElements.Bindings.SerializedObjectBindingContext.BindPropertyRelative (UnityEngine.UIElements.IBindable field, UnityEditor.SerializedProperty parentProperty) (at <dfb6114cbc8f47d49a0a812a5562a1f9>:0) UnityEditor.UIElements.Bindings.SerializedObjectBindingContext.BindTree (UnityEngine.UIElements.VisualElement element, UnityEditor.SerializedProperty parentProperty) (at <dfb6114cbc8f47d49a0a812a5562a1f9>:0) UnityEditor.UIElements.Bindings.SerializedObjectBindingContext.ContinueBinding (UnityEngine.UIElements.VisualElement element, UnityEditor.SerializedProperty parentProperty) (at <dfb6114cbc8f47d49a0a812a5562a1f9>:0) UnityEditor.UIElements.Bindings.DefaultSerializedObjectBindingImplementation+BindingRequest.Bind (UnityEngine.UIElements.VisualElement element) (at <dfb6114cbc8f47d49a0a812a5562a1f9>:0) UnityEngine.UIElements.VisualTreeBindingsUpdater.Update () (at <d46c07da13f941aeb9b5f49c78214485>:0) UnityEngine.UIElements.VisualTreeUpdater.UpdateVisualTreePhase (UnityEngine.UIElements.VisualTreeUpdatePhase phase) (at <d46c07da13f941aeb9b5f49c78214485>:0) UnityEngine.UIElements.Panel.UpdateBindings () (at <d46c07da13f941aeb9b5f49c78214485>:0) UnityEngine.UIElements.UIElementsUtility.UnityEngine.UIElements.IUIElementsUtility.UpdateSchedulers () (at <d46c07da13f941aeb9b5f49c78214485>:0) UnityEngine.UIElements.UIEventRegistration.UpdateSchedulers () (at <d46c07da13f941aeb9b5f49c78214485>:0) UnityEditor.RetainedMode.UpdateSchedulers () (at <dfb6114cbc8f47d49a0a812a5562a1f9>:0)

最新推荐

recommend-type

MOBILEYE:智能车速辅助系统,车道保持辅助系统和AEB介绍.pdf

本文档是智能驾驶行业摄像头传感器巨头MOBILEYE关于其智能车速辅助系统,车道保持辅助系统和AEB技术介绍,欢迎下载
recommend-type

euro-ncap-aeb-lss-vru-test-protocol-v400.pdf

AEB/LSS VRU Systems Test protocol Euro-NCAP 2023 AEB/LSS测试要求
recommend-type

zigbee-cluster-library-specification

最新的zigbee-cluster-library-specification说明文档。
recommend-type

管理建模和仿真的文件

管理Boualem Benatallah引用此版本:布阿利姆·贝纳塔拉。管理建模和仿真。约瑟夫-傅立叶大学-格勒诺布尔第一大学,1996年。法语。NNT:电话:00345357HAL ID:电话:00345357https://theses.hal.science/tel-003453572008年12月9日提交HAL是一个多学科的开放存取档案馆,用于存放和传播科学研究论文,无论它们是否被公开。论文可以来自法国或国外的教学和研究机构,也可以来自公共或私人研究中心。L’archive ouverte pluridisciplinaire
recommend-type

实现实时数据湖架构:Kafka与Hive集成

![实现实时数据湖架构:Kafka与Hive集成](https://img-blog.csdnimg.cn/img_convert/10eb2e6972b3b6086286fc64c0b3ee41.jpeg) # 1. 实时数据湖架构概述** 实时数据湖是一种现代数据管理架构,它允许企业以低延迟的方式收集、存储和处理大量数据。与传统数据仓库不同,实时数据湖不依赖于预先定义的模式,而是采用灵活的架构,可以处理各种数据类型和格式。这种架构为企业提供了以下优势: - **实时洞察:**实时数据湖允许企业访问最新的数据,从而做出更明智的决策。 - **数据民主化:**实时数据湖使各种利益相关者都可
recommend-type

2. 通过python绘制y=e-xsin(2πx)图像

可以使用matplotlib库来绘制这个函数的图像。以下是一段示例代码: ```python import numpy as np import matplotlib.pyplot as plt def func(x): return np.exp(-x) * np.sin(2 * np.pi * x) x = np.linspace(0, 5, 500) y = func(x) plt.plot(x, y) plt.xlabel('x') plt.ylabel('y') plt.title('y = e^{-x} sin(2πx)') plt.show() ``` 运行这段
recommend-type

JSBSim Reference Manual

JSBSim参考手册,其中包含JSBSim简介,JSBSim配置文件xml的编写语法,编程手册以及一些应用实例等。其中有部分内容还没有写完,估计有生之年很难看到完整版了,但是内容还是很有参考价值的。
recommend-type

"互动学习:行动中的多样性与论文攻读经历"

多样性她- 事实上SCI NCES你的时间表ECOLEDO C Tora SC和NCESPOUR l’Ingén学习互动,互动学习以行动为中心的强化学习学会互动,互动学习,以行动为中心的强化学习计算机科学博士论文于2021年9月28日在Villeneuve d'Asq公开支持马修·瑟林评审团主席法布里斯·勒菲弗尔阿维尼翁大学教授论文指导奥利维尔·皮耶昆谷歌研究教授:智囊团论文联合主任菲利普·普雷教授,大学。里尔/CRISTAL/因里亚报告员奥利维耶·西格德索邦大学报告员卢多维奇·德诺耶教授,Facebook /索邦大学审查员越南圣迈IMT Atlantic高级讲师邀请弗洛里安·斯特鲁布博士,Deepmind对于那些及时看到自己错误的人...3谢谢你首先,我要感谢我的两位博士生导师Olivier和Philippe。奥利维尔,"站在巨人的肩膀上"这句话对你来说完全有意义了。从科学上讲,你知道在这篇论文的(许多)错误中,你是我可以依
recommend-type

实现实时监控告警系统:Kafka与Grafana整合

![实现实时监控告警系统:Kafka与Grafana整合](https://imgconvert.csdnimg.cn/aHR0cHM6Ly9tbWJpei5xcGljLmNuL21tYml6X2pwZy9BVldpY3ladXVDbEZpY1pLWmw2bUVaWXFUcEdLT1VDdkxRSmQxZXB5R1lxaWNlUjA2c0hFek5Qc3FyRktudFF1VDMxQVl3QTRXV2lhSWFRMEFRc0I1cW1ZOGcvNjQw?x-oss-process=image/format,png) # 1.1 Kafka集群架构 Kafka集群由多个称为代理的服务器组成,这
recommend-type

导入numpy库,创建两个包含9个随机数的3*3的矩阵,将两个矩阵分别打印出来,计算两个数组的点积并打印出来。(random.randn()、dot()函数)

可以的,以下是代码实现: ```python import numpy as np # 创建两个包含9个随机数的3*3的矩阵 matrix1 = np.random.randn(3, 3) matrix2 = np.random.randn(3, 3) # 打印两个矩阵 print("Matrix 1:\n", matrix1) print("Matrix 2:\n", matrix2) # 计算两个数组的点积并打印出来 dot_product = np.dot(matrix1, matrix2) print("Dot product:\n", dot_product) ``` 希望