快进9.5s?? 速度为原来的9080/9186
KUAIJIN=9.5 ff=9080/9186
调节前:??????????????????????????????????????????????????????? 调节后:
#time:2022/4/12 19:42
#author:yigeshuaige
#
KUAIJIN=9.5
ff=9080/9186
file_path = "zimu.txt" ##file_path为路径
SWITCH=1#调试开关,勿动
def is_number(data):
try:
int(data)
return True
except ValueError:
pass
return False
def thans_str(data,num):
if num==2:
if data<10:
return '0'+str(data)
else:
return str(data)
if num==3:
if data<10:
return '00'+str(data)
elif data<100:
return '0'+str(data)
else:
return str(data)
print(thans_str(99,3)+':'+thans_str(9,2))
print(is_number('1'))
print(int('12'))
print(ff)
with open(file_path, 'r', encoding='utf-8') as f: # 用UTF_8编码打路径文件,否则出现错误UnicodeDecodeErrorbyte 0xad in position
file = f.read(); # 以str类型读取
print(type(file)) # 打印file的类型
time_list=[0,0,0,0]
find_flag = 0;
ans = ''
sum_of_str = file.count(''); # 统计字符个数,‘’为空字符,即任意字符都计数
print('字符个数总计:', sum_of_str);
k=0
i=0
time_f=0.0
if SWITCH==0:
sum_of_str=100
ans=''
while i<sum_of_str-1:
# print(file[i])
if(is_number(file[i]) and is_number(file[i+1]) and file[i+2]==':'):
print('i: ', i, end=' ')
k=i
# print(file[k+1:k+3])
time_list[0]=int(file[k:k+2])
time_list[1] = int(file[k+3:k + 5])
time_list[2] = int(file[k+6:k + 8])
time_list[3] = int(file[k+9:k + 12])
print(time_list, end='-----> ')
time_f=time_list[0]*3600+time_list[1]*60+time_list[2]*1+time_list[3]/1000
time_f=time_f*ff-KUAIJIN
time_list[3]=int(1000*(time_f%1))
time_f=time_f-time_list[3]/1000
time_list[2] = int(time_f % 60)
time_f= (time_f-time_list[2])/60
time_list[1] = int(time_f % 60)
time_f = (time_f - time_list[1])/60
time_list[0] = int(time_f % 60)
print(time_list)
ans=ans+thans_str(time_list[0],2)+':'+thans_str(time_list[1],2)+':'+thans_str(time_list[2],2)+','+thans_str(time_list[3],3)
i=i+11
print('')
else:
ans=ans+file[i]
i=i+1
print(ans)
fobj = open('ZIMU.srt', 'w', encoding='utf-8')
fobj.write(ans)
fobj.close()
?
|