'Formatting Integer in Python
This is the Request I get from an BMD Hyperdeck, it contains the Video-files on the SD-Cards an the lengths of the Videos. I need the lengths of every file, separate in a List for my Code. What would be the right way to something like this?
b'206 disk list:\r\nslot id: 1\r\n1: Timecode.mp4 H.264 1080p25 00:01:00:00\r\n2: Video_1.mp4 H.264 1080p25 00:00:09:07\r\n3: Video_2.mp4 H.264 1080p25 00:00:07:04\r\n4: Video_3.mp4 H.264 1080p25 00:00:10:19\r\n5: Video_4.mp4 H.264 1080p25 00:00:04:16\r\n6: Video_5.mp4 H.264 1080p25 00:00:05:21\r\n\r\n'
Solution 1:[1]
This can be achieved using the regular expressions and findall:
import re
a = b"206 disk list:\r\nslot id: 1\r\n1: Timecode.mp4 H.264 1080p25 00:01:00:00\r\n2: Video_1.mp4 H.264 1080p25 00:00:09:07\r\n3: Video_2.mp4 H.264 1080p25 00:00:07:04\r\n4: Video_3.mp4 H.264 1080p25 00:00:10:19\r\n5: Video_4.mp4 H.264 1080p25 00:00:04:16\r\n6: Video_5.mp4 H.264 1080p25 00:00:05:21\r\n\r\n"
str_a = str(a)
length = re.findall(r"[0-9]{2}:[0-9]{2}:[0-9]{2}:[0:9]{2}", str_a)
print(length)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Floh |
