when calling readlines()
in a .srt file, I got a list of characters with a lot of leading and trailing spaces, as shown below
with open(infile) as f: r=f.readlines() return r
I got this list
['\xef\xbb\xbf1\r\n', '00:00:00,000 --> 00:00:03,000\r\n', "[D. Evans] Now that you've written your first Python program,\r\n",'\r\n', '2\r\n', '00:00:03,000 --> 00:00:06,000\r\n', 'you might be wondering why we need to invent new languages like Python\r\n', '\r\n']
I just included a few elements for brevity. How to clear this list so that I can remove all whitespace characters and get only the relevant elements, such as
['1','00:00:00,000 --> 00:00:03,000',"[D. Evans] Now that you've written your first Python program"...]
damon source share