Hello! There is data:
s="""#EXTINF:0,FREE8 КАНАЛ udp://@239.255.0.107:1234 #EXTINF:0,Русская ночь udp://@239.255.6.102:1234""" Need to get:
udp://@239.255.0.107:1234 #EXTINF:0,FREE8 КАНАЛ udp://@239.255.6.102:1234 #EXTINF:0,Русская ночь Hello! There is data:
s="""#EXTINF:0,FREE8 КАНАЛ udp://@239.255.0.107:1234 #EXTINF:0,Русская ночь udp://@239.255.6.102:1234""" Need to get:
udp://@239.255.0.107:1234 #EXTINF:0,FREE8 КАНАЛ udp://@239.255.6.102:1234 #EXTINF:0,Русская ночь Option with regular expressions:
import re m = re.findall(r'(#.+)\n?\s*(udp:.+)\n?\s*', s, re.IGNORECASE) for item in m: print "%s %s" % (item[1], item[0]) It's all right? True checks are not done here any ...
ls = s.split('\n') for i in range(len(ls) / 2): print ls[i*2+1].strip() + " " + ls[i*2].strip() Source: https://ru.stackoverflow.com/questions/206997/
All Articles