20230809 python3을 사용하여 WIN10에서 Google 번역으로 얻은 SRT 형식 자막(DOCX) 처리
2023/8/9 19:02
저는 다큐멘터리나 외국 영상 보는 걸 좋아해서 Cut/PR2023/AUTOSUB를 통해 자막을 확인한 후 구글 번역을 이용하면 중국어 간체 DOCX 문서인지 확인할 수 있습니다.
DOCX 문서가 TXT 문서로 변환된 후 최종 필수 중국어 간체 SRT 문서를 얻으려면 자막 일련번호를 수정해야 합니다.
google.py
#f=열기("./1574/%03d.ts"%(n+1),"wb")
f=열기("12.txt","wb")
#f = open("p:\\ts\\1574.txt")
f1 = open("1.txt")
#for n in range(1,4000):
for n in range(1,4560):
line = f1.readline()
#f.write(response.content)
#f.write(line)
f.decode().write(line)
f.닫기()
google12.py
J:\! ! ! ! 문서 20230625\en2cn\20230809 python3을 사용하여 WIN10\py>python google12.py > test.srt에서 Google 번역으로 얻은 SRT 형식 자막(DOCX)을 처리합니다.
f_path=r'1.txt'
온도 = 1
쉬하오 = 1;
open(f_path)을 f로 사용:
line = f.readlines()
줄 안의 줄:
if temp == 1:
print(str(xuhao))
temp=0
else:
if len(line) == 1:
#print("jiangedian!")
temp=1
xuhao = xuhao+1
print( 라인.rstrip())
txt2srt3all.py
[디렉토리에 있는 모든 ANSI 인코딩 TXT 자막을 SRT 자막으로 처리하지만, 자막 디렉터리는 처리하지 않습니다! ]
# 코딩=utf-8
가져오기 운영 체제
# 현재 디렉터리
경로 가져오기 = os.getcwd()
# 현재 디렉터리의 모든 파일 보기 files
= os.listdir(path)
txt' #f_path=파일 임시 = 1 xuhao = 1; #open(f_path)을 f로 사용:
open(file)을 f로 사용:
line = f.readlines()
for line in line:
if temp == 1:
#print(str(xuhao))
#f.decode().write(line)
#f2.decode( ).write(str(xuhao))
#f2.write(str(xuhao))
f2.write(str(xuhao).encode())
f2.write(str('\n').encode())
temp= 0
else:
if len(line) == 1:
#print("jiangedian!")
temp=1
xuhao = xuhao+1
#print(line.rstrip())
#f.decode().write(line)
#f2.decode().write(line.rstrip())
#f2.write(line.rstrip())
f2.write(line.encode())
#f=open(new_file,"wb")
f2.close()
로그:
J:\! ! ! !
문서 20230625\en2cn\20230809 WIN10에서 python3을 사용하여 Google Translate\ansi의 TXT>dir 드라이브 J 에서 얻은 SRT 형식 자막(DOCX)을 처리합니다. 드라이브 J의 볼륨은 18680688682입니다
. 볼륨의 일련 번호는 2A59-69C0입니다.
제이:\! ! ! ! 문서 20230625\en2cn\20230809 python3을 사용하여 WIN10\ansi TXT 디렉터리에서 Google 번역으로 얻은 SRT 형식 자막(DOCX)을 처리합니다.
2023/08/09 19:11 <DIR>
.2023/08/09 19:11 <DIR> ..
2023/08/09 12:22 67,713 8월 7.txt
2023/08/09 12:22 113,997 AC3EN2 .silhouette .txt
2023/08/09 12:22 67,713 path_to_your_word_file.txt 2023/08/09
12:22 75,347 Red.Eye.2005.2160p.BluRay.REMUX.HEVC.DTS-HD.MA.5.1-FGT.eng9.txt
2023 /08/09 19:11 1,715 txt2srt3all.py
2023/08/07 22:29 1,671 txt2srt3xuhao56.py
6개 파일 328,156바이트
2개 디렉토리 50,770,313,216 사용 가능 바이트
제이:\! ! ! ! 문서 20230625\en2cn\20230809 python3을 사용하여 WIN10\ansi의 TXT>python txt2srt3all.py에서 Google 번역으로 얻은 SRT 형식 자막(DOCX)을 처리합니다.
제이:\! ! ! !
문서 20230625\en2cn\20230809 WIN10에서 python3을 사용하여 Google Translate\ansi의 TXT>dir 드라이브 J 에서 얻은 SRT 형식 자막(DOCX)을 처리합니다. 드라이브 J의 볼륨은 18680688682입니다
. 볼륨의 일련 번호는 2A59-69C0입니다.
제이:\! ! ! ! 문서 20230625\en2cn\20230809 python3을 사용하여 WIN10\ansi TXT 디렉터리에서 Google 번역으로 얻은 SRT 형식 자막(DOCX)을 처리합니다.
2023/08/09 19:11 <DIR> .. 2023/08/09
19:11 <DIR> ..
2023/08/09 19:11 71,024 8월 7.cn.srt
2023/08/09 12:22 67,713 8월 7.txt
2023/08/09 19:11 120,955 AC3EN2.silhouette.cn.srt
2023/08/09 12:22 113,997 AC3EN2.silhouette.txt
2023/08/09 19:11 71,024 path_to_your_word_ file.cn.srt
202 3/ 08/09 12:22 67,713 path_to_your_word_file.txt
2023/08/09 19:11 81,213 Red.Eye.2005.2160p.BluRay.REMUX.HEVC.DTS-HD.MA.5.1-FGT.eng9.cn.srt
2023/08 /09 12:22 75,347 Red.Eye.2005.2160p.BluRay.REMUX.HEVC.DTS-HD.MA.5.1-FGT.eng9.txt
2023/08/09 19:11 1,715 txt2srt3all.py
2023/08/07 22:29 1,671 txt2srt3xuhao56.py
10개 파일 672,372바이트
2개 디렉터리 50,769,960,960 사용 가능한 바이트
제이:\! ! ! ! 문서 20230625\en2cn\20230809 python3을 사용하여 WIN10\ansi TXT>에서 Google 번역으로 얻은 SRT 형식 자막(DOCX) 처리
utf8txt2srt3all.py
[디렉토리에 있는 모든 UTF8 인코딩 TXT 자막을 SRT 자막으로 처리하지만, 자막 디렉터리는 처리하지 않습니다! ]
# 코딩=utf-8
가져오기 운영 체제
# 현재 디렉터리
경로 가져오기 = os.getcwd()
# 현재 디렉터리의 모든 파일 보기 files
= os.listdir(path)
인코딩="UTF-8") 임시 = 1 xuhao = 1; #open(f_path)을 f로 사용:
#open(file)을 f로 사용:
#open(new_file, "w", 인코딩="UTF-8")을 txt_file로 사용:
#open(file, "w", 인코딩="UTF-8")을 f로 사용 :
open(file, "r", 인코딩="UTF-8")을 f로 사용:
line = f.readlines()
for line in 라인:
if temp == 1:
#f2.write(str(xuhao).encode ())
#f2.write(str('\n').encode())
f2.write(str(xuhao))
f2.write(str('\n'))
temp=0
else:
if len(line ) == 1:
temp=1
xuhao = xuhao+1
#f2.write(line.encode())
f2.write(줄)
f2.닫기()
참고:
https://pythonjishu.com/nwbuyryewwscpxl/Python
을 사용하여 파일 이름을 일괄적으로 바꾸는 방법
python docx utf8 읽기 및 쓰기
https://deepinout.com/python/python-qa/t_how-to-read-and-write-unicode-utf-8-files-in-python.html
유니코드를 읽고 쓰는 방법 Python(UTF-8) 파일이요?
UTF8 스크립트의 디버깅 기록은 매우 다르게 작성됩니다!
Microsoft Windows [버전 10.0.19045.2311]
(c) Microsoft Corporation. 판권 소유.
C:\Users\관리자>cd J:\! ! ! ! 문서 정렬 20230625\en2cn\20230809 python3을 사용하여 WIN10에서 Google 번역으로 얻은 SRT 형식 자막(DOCX)\utf8i TXT 처리
C:\사용자\관리자>j:
제이:\! ! ! ! 문서 20230625\en2cn\20230809 WIN10에서 python3을 사용하여 Google Translate\utf8i의 TXT>dir 드라이브 J에서 얻은 SRT 형식 자막(DOCX)을 처리합니다.
드라이브 J의 볼륨은 18680688682입니다.
볼륨의 일련 번호는 2A59-69C0입니다.
제이:\! ! ! ! 문서 20230625\en2cn\20230809 python3을 사용하여 WIN10\utf8i TXT 디렉터리에서 Google 번역으로 얻은 SRT 형식 자막(DOCX)을 처리합니다.
2023/08/09 19:14 <DIR>
.2023/08/09 19:14 <DIR> ..
2023/08/09 12:27 78,650 8월 7.txt
2023/08/09 12:27 133,327 AC3EN2 .silhouette .txt
2023/08/09 12:27 78,650 path_to_save_txt+utf8_file.txt
2023/08/09 12:27 78,650 path_to_your_word_file.txt
2023/08/09 19:11 1,715 txt2srt3all.py
5개 파일 370,992 바이트
2 디렉터리 50,769,956,864 사용 가능한 바이트
제이:\! ! ! ! 문서 20230625\en2cn\20230809 python3을 사용하여 WIN10\utf8i TXT>
J:\! 에서 Google 번역으로 얻은 SRT 형식 자막(DOCX)을 처리합니다. ! ! ! Documentation 20230625\en2cn\20230809 WIN10에서 python3을 사용하여 Google Translate\utf8i's TXT>python txt2srt3all.py에서 얻은 SRT 형식 자막(DOCX)을 처리합니다. 역추적(
가장 최근 호출 마지막):
File "J:\!!! Documentation Organize 20230625\ en2cn\20230809 python3을 사용하여 WIN10\utf8i의 TXT\txt2srt3all.py", 34행, <module> 행 = f.readlines() UnicodeDecodeError:
'
gbk ' codec can'에서 Google 번역으로 얻은 SRT 형식 자막(DOCX)을 처리합니다. t 위치 82의 바이트 0xb7을 디코딩함: 잘못된 멀티바이트 시퀀스
제이:\! ! ! ! 문서 20230625\en2cn\20230809 python3을 사용하여 WIN10\utf8i의 TXT>python txt2srt3all.py에서 Google 번역으로 얻은 SRT 형식 자막(DOCX)을 처리합니다.
제이:\! ! ! ! 문서 20230625\en2cn\20230809 Google Translate\utf8i's TXT>python utf8txt2srt3all.py에서 얻은 SRT 형식 자막(DOCX)을 처리하려면 WIN10에서 python3을 사용하세요. 역추적(가장 최근 호출 마지막): File "J:\!!! Documentation Organize
20230625
\ en2cn\20230809 WIN10에서 python3을 사용하여 Google Translate\utf8i의 TXT\utf8txt2srt3all.py", 23행, <module> f2 = open(new_file, "wb",
인코딩 ="UTF- 에서 얻은 SRT 형식 자막(DOCX)을 처리합니다. 8")
ValueError: 바이너리 모드는 인코딩 인수를 사용하지 않습니다.
제이:\! ! ! ! 문서 20230625\en2cn\20230809 Google Translate\utf8i's TXT>python utf8txt2srt3all.py에서 얻은 SRT 형식 자막(DOCX)을 처리하려면 WIN10에서 python3을 사용하세요. 역추적(가장 최근 호출
마지막):
File "J:\!!! Documentation Organize 20230625\ en2cn\20230809 python3을 사용하여 WIN10\utf8i의 TXT\utf8txt2srt3all.py", 33행, <module> 행 = f.readlines()
io.UnsupportedOperation
: 읽을 수 없음 에서 Google 번역으로 얻은 SRT 형식 자막(DOCX)을 처리합니다.
제이:\! ! ! ! 문서 20230625\en2cn\20230809 Google Translate\utf8i's TXT>python utf8txt2srt3all.py에서 얻은 SRT 형식 자막(DOCX)을 처리하려면 WIN10에서 python3을 사용하세요. 역추적(가장 최근 호출
마지막):
File "J:\!!! Documentation Organize 20230625\ en2cn\20230809 python3을 사용하여 <module> f2.write(str(xuhao).encode
( )) 의 WIN10\utf8i's TXT\utf8txt2srt3all.py", 38행에서 Google 번역으로 얻은 SRT 형식 자막(DOCX)을 처리합니다
. write() 인수는 바이트가 아닌 str이어야 합니다.
제이:\! ! ! ! 문서 20230625\en2cn\20230809 Google Translate\utf8i's TXT>python utf8txt2srt3all.py에서 얻은 SRT 형식 자막(DOCX)을 처리하려면 WIN10에서 python3을 사용하세요. 역추적(가장 최근 호출 마지막): File "J:\!!! Documentation Organize
20230625
\ en2cn\20230809 python3을 사용하여 <module> f2.write(str
('\n' ) .encode() 의 WIN10\utf8i's TXT\utf8txt2srt3all.py", 40행에서 Google 번역으로 얻은 SRT 형식 자막(DOCX)을 처리합니다. )
TypeError: write() 인수는 바이트가 아닌 str이어야 합니다.
제이:\! ! ! ! 문서 20230625\en2cn\20230809 python3을 사용하여 WIN10\utf8i의 TXT>python utf8txt2srt3all.py에서 Google 번역으로 얻은 SRT 형식 자막(DOCX)을 처리합니다.
제이:\! ! ! ! 문서 20230625\en2cn\20230809 python3을 사용하여 WIN10\utf8i의 TXT>python utf8txt2srt3all.py에서 Google 번역으로 얻은 SRT 형식 자막(DOCX)을 처리합니다.
제이:\! ! ! ! 문서 20230625\en2cn\20230809 python3을 사용하여 WIN10\utf8i의 TXT>python utf8txt2srt3all.py에서 Google 번역으로 얻은 SRT 형식 자막(DOCX)을 처리합니다.
제이:\! ! ! ! 문서 20230625\en2cn\20230809 WIN10에서 python3을 사용하여 Google Translate\utf8i의 TXT>dir 드라이브 J에서 얻은 SRT 형식 자막(DOCX)을 처리합니다.
드라이브 J의 볼륨은 18680688682입니다.
볼륨의 일련 번호는 2A59-69C0입니다.
제이:\! ! ! ! 문서 20230625\en2cn\20230809 python3을 사용하여 WIN10\utf8i TXT 디렉터리에서 Google 번역으로 얻은 SRT 형식 자막(DOCX)을 처리합니다.
2023/08/09 19:29 <디렉터리> .
2023/08/09 19:29 <DIR> ..
2023/08/09 19:29 75,580 8月7日.cn.srt
2023/08/09 12:27 78,650 8月7日.txt
2023/08/09 19:29 128,367 AC3EN2.剪影.cn.srt
2023/08/09 12:27 133,327 AC3EN2.剪影.txt
2023/08/09 19:29 75,580 path_to_save_txt+utf8_file.cn.srt
2023/08/ 09 12:27 78,650 path_to_save_txt+utf8_file.txt
2023/08/09 19:29 75,580 path_to_your_word_file.cn.srt
2023/08/09 12:27 78,650 path_to_your_word_file.txt
2023/08/09 19:29 86,176 Red.Eye.200 5.2160p.BluRay.REMUX .HEVC.DTS-HD.MA.5.1-FGT.eng9.cn.srt
2023/08/09 19:28 89,228 Red.Eye.2005.2160p.BluRay.REMUX.HEVC.DTS-HD.MA.5.1-FGT.eng9.txt
2023/08/09 19:11 1,715 txt2srt3all.py
2023/08 /09 19:24 1,568 utf8txt2srt3all.py
12개 파일 903,071바이트
2개 디렉터리 50,767,888,384 사용 가능한 바이트
제이:\! ! ! ! 문서 20230625\en2cn\20230809 python3을 사용하여 WIN10\utf8i TXT>에서 Google 번역으로 얻은 SRT 형식 자막(DOCX) 처리