Python:变更输出文件的一部分的大写
我正在尝试更改旨在检测文件中文本语言的Python脚本。它检测到语言&在文件名末尾以ISO格式检测到的语言。不幸的是,它以所有小写都输出Lang代码。
现在,我在脚本中的几个位置找到了此sub_lang = fileName [-3] .lower()
,但不幸的是将其更改为.upper
毫无用处来更改输出。
所有文件将以.lan.vtt
或.eng.srt
或.123.SSA
带有3个字符扩展以及3字符语言代码。我编辑的脚本具有输出3个字符或2个字符ISO代码的能力,但是对于我的使用,我将始终使用3个。
我认为这是一个简单的更改,但是我发现的所有内容似乎都没有用
I'm trying to change a python script that is designed to detect the language of the text in a file. It detects the language & puts the language detected in ISO format at the end of the filename. Unfortunately it outputs the Lang code in all lowercase.
Now a few places in the script I found this sub_lang = filename[-3].lower()
but unfortunately changing those to .upper
does nothing to change the output.
All files will end in .LAN.vtt
or .ENG.srt
or .123.ssa
with a 3 character extension as well as a 3 character LANGUAGE code. The script I'm editing has the ability to output either 3 character or 2 character ISO codes, but for my use I will always be using 3.
I thought this would be a simple change but everything I've found does not seem to work
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现自己的错误,我在争论错误的地方。
有一条行
,当我添加
.upper()
时,它会按照我的意愿进行更改。我一直以为较早的参数指定.lower()
这是问题所在,但这不是这样:
如果有人有任何其他信息,我直到明天才能将其标记为解决要添加
以便答案是用
.upper()
标签,只需要将其附加到正确的字段上I discovered my error, I was arguing the wrong place.
There a line
that when I added the
.upper()
it altered it as I wanted. I had thought since the earlier argument specified the.lower()
it was the problem, but it was notThe context of this:
I'll not mark it as solved until tomorrow if anyone has any further information to add
So the answer is with the
.upper()
tag, it just needs to be attached to the correct field