Python: How to read text between two empty lines into a string -
I am beginning with programming and Python, and I'm writing a script to stuff with .rt subtitle files Am My problem is that I do not know how to: Read through a file, analyze the text between the beginning of the text and the first blank line, and then between the blank line and the next empty line to the end of the file (for example , Calculate the length of a part like "analyze", convert the second part to the numbers etc.).
You can read about the .srt format specification and see an example (type: plain); There is an empty line at the end of the file, I want to compare the number of characters in the comparison of the display time / duration of each subtitle. From the beginning of the file, each subtitle (with its number, duration information and text) is separated from an empty line (a "\ n", I would like them sth like Read the subtitle text, which can be a 1-3 line with a line break, calculate its character length. Read the duration, convert duration in seconds. Read line line (to be able to output it somewhere with my results, for example, "the length of the row 44 is 4.54"). I can do other things easily, but I'm pretty sure how to go to the full file and Python: Find the end of the text of each subtitle, characters in each line Calculate the length of, add, read the period, divide it, output it with the line number and do this with the next subtitle until you file. If this was a subtitle, then I could do it easily, but I'm not sure how to check on one and then look for the next one. I am looking for 2 hours for this and can not find anything like this. A powerful tool can help you to solve this type of regular expression processing. You can use a regular expression to match or parse against a single record or an entire file. If you do not know about reggae in dragon, then I highly recommend that you do some tutorials on this topic ... and this will give you so many ideas that how it can be applied to your problem. There are many great references to the subject, but here's the only one: if "N" line and line (line) == 2: ). Time Code is always a "->" And always ends in three digits, so if I have a string, then I will know where it is. The problem is, I have to do the following in any way:
Comments
Post a Comment