记录main.py调用另一个python文件的直接引用函数方法
2025-05-03 01:13:03 241 分享链接 开发笔记 python
main.py
from merge import merge_srt_files
# 示例调用
if __name__ == "__main__":
input_files = ["file1.srt", "file2.srt"]
output_file = "merged.srt"
merge_srt_files(input_files, output_file)
merge.py
import os
from datetime import datetime, timedelta
def parse_time(time_str):
return datetime.strptime(time_str, '%H:%M:%S,%f')
def merge_srt_files(input_files, output_file):
print(input_files)
print(output_file)
time_line = "00:00:03,813 --> 00:00:04,943"
start_time_str, end_time_str = time_line.split(' --> ')
try:
print(parse_time(start_time_str))
print(end_time_str)
print(timedelta())
except ValueError as e:
print(f"解析时间时出错: {e}, 时间字符串: {time_line}")
最近更新
- 2025-09-22 01:46
- 可以直接在content.js里面写一个函数获取blob数据实现自定义下载吗?
- 2025-09-22 00:17
- background.js中可通过注入脚本的方法实现获取blobUrl实现自定义下载
- 2025-09-21 17:45
- 通过MutationObserver 开发chrome浏览器扩展的实例
- 2025-09-21 17:23
- MutationObserver实例中mutation.type为childList时addedNodes节点的遍历方法。
- 2025-09-21 17:21
- MutationObserver实例中mutation.type为childList时addedNodes节点的筛选方法。
- 2025-09-21 17:09
- MutationObserver实例中mutation.type为childList时addedNodes节点具体的方法与属性。
- 2025-09-21 16:56
- MutationObserver实例中mutation.type突变类型为childList时有哪些属性、方法?
- 2025-09-21 16:46
- MutationObserver实例中mutation三种不同突变类型的属性与方法?
- 2025-09-21 16:34
- MutationObserver实例中mutation.type突变类型为attributes时有哪些属性、方法?
- 2025-09-15 18:42
- 用豆包图像生成的功能批量创作小说推文的提示词