Как сделать несколько списков, как это:Изменение списка в Python
['The Lord of the Rings: The Fellowship of the Ring (2001)']
['The Lord of the Rings: The Two Towers (2002)']
['"5 Second Movies" (2007) {The Lord of the Rings and the Two Towers (#1.63)}']
В один список, как это:
['The Lord of the Rings: The Fellowship of the Ring (2001)',
'The Lord of the Rings: The Two Towers (2002)',
'"5 Second Movies" (2007) {The Lord of the Rings and the Two Towers (#1.63)}']
Я попытался это:
x = open("ratings.list.txt","r")
movread = x.readlines()
x.close()
#s = raw_input('Search: ').lower()
for ns in movread:
if 'the lord of the' in ns.lower():
d = re.split('\s+',ns,4)
Title = d[4].rstrip()
Rating= d[3]
lists = [Title]
combined = [item for sublist in lists for item in sublist]
print combined
Но его дает меня этот выход:
['T', 'h', 'e', ' ', 'L', 'o', 'r', 'd', ' ', 'o', 'f', ' ', 't', 'h', 'e', ' ', 'R', 'i', 'n', 'g', 's', ':', ' ', 'T', 'h', 'e', ' ', 'R', 'e', 't', 'u', 'r', 'n', ' ', 'o', 'f', ' ', 't', 'h', 'e', ' ', 'K', 'i', 'n', 'g', ' ', '(', '2', '0', '0', '3', ')']
['T', 'h', 'e', ' ', 'L', 'o', 'r', 'd', ' ', 'o', 'f', ' ', 't', 'h', 'e', ' ', 'R', 'i', 'n', 'g', 's', ':', ' ', 'T', 'h', 'e', ' ', 'F', 'e', 'l', 'l', 'o', 'w', 's', 'h', 'i', 'p', ' ', 'o', 'f', ' ', 't', 'h', 'e', ' ', 'R', 'i', 'n', 'g', ' ', '(', '2', '0', '0', '1', ')']
Спасибо за помощь, ребята: D
UPDATE
Файл выглядеть следующим образом (его список всех фильмов на IMDB, поэтому размер огромен):
New Distribution Votes Rank Title
0000000125 1196672 9.2 The Shawshank Redemption (1994)
0000000125 829707 9.2 The Godfather (1972)
0000000124 547511 9.0 The Godfather: Part II (1974)
0000000124 1160800 8.9 The Dark Knight (2008)
0000000124 920221 8.9 Pulp Fiction (1994)
0000000124 358790 8.9 Il buono, il brutto, il cattivo. (1966)
000000.9 Schindler's List (1993)
0000000133 297241 8.9 12 Angry Men (1957)
0000000124 854409 8.9 The Lord of the Rings: The Return of the King (2003)
000000.8 Fight Club (1999)
0000000124 880827 8.8 The Lord of the Rings: The Fellowship of the Ring (2001)
000000.8 Star Wars: Episode V - The Empire Strikes Back (1980)
0000000124 953140 8.7 Inception (2010)
Как насчет только '[sub [0] для sub в оригинале]'? –
Предлагаю вам прочитать файл и разбить его по символам. –
Как это сделать? im не хорошо на python только начал с этого! @ Stupid.Fat.Cat –