简体   繁体   English

AWS 读取 utf-8 文件 pycaption.detect_format 返回无

[英]AWS reading utf-8 file pycaption.detect_format returns None

Python version: 3.5-slim-buster Module: pycaption Python 版本:3.5-slim-buster 模块:pycaption

When reading caption.srt that is us-ascii encoded from s3 bucket:当读取从 s3 存储桶编码的 us-ascii 的 caption.srt 时:

obj.get()['Body'].read()
print(pycaption.detect_format(body.decode()))

I get a desired response我得到了想要的回应

<class 'pycaption.srt.SRTReader'> 

But when reading utf-8 encoded s3.srt file但是在读取 utf-8 编码的 s3.srt 文件时

pycaption can't detect format response: pycaption 无法检测到格式响应:

None

I have tried:我努力了:

obj.get()['Body'].read().decode('utf-8')

print(pycaption.detect_format(body))

But with no luck但没有运气

In the end the issue was in DOS newlines CR/LF that I converted to DOS newlines CR/LF.最后问题出在我转换为 DOS 换行 CR/LF 的 DOS 换行 CR/LF 中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM