@denislysenko
data engineer

Как строку похожую на список превратить в список?

Есть строка:

["A Dog's Purpose;2017", 'Fist Fight;2017', 'The Lego Batman Movie;2017', 'Jim Gaffigan: Cinco;2017', 'The Big Sick;2017', 'The Boss Baby;2017', 'Bill Burr: Walk Your Way Out;2017', 'Neal Brennan: 3 Mics;2017', 'Dave Chappelle: The Age of Spin;2017', 'CHiPS;2017', 'Table 19;2017', 'Dave Chappelle: Deep in the Heart of Texas;2017', 'Baywatch;2017', 'Snatched;2017', 'Sandy Wexler;2017', 'Win It All;2017', 'Captain Underpants: The First Epic Movie;2017', 'Cars 3;2017', 'Rough Night;2017', 'Despicable Me 3;2017', 'The Meyerowitz Stories;2017', 'War Machine;2017', 'Vir Das: Abroad Understanding;2017', "Norm Macdonald: Hitler's Dog, Gossip & Trickery;2017", 'Goon: Last of the Enforcers;2017', 'Oh, Hello: On Broadway;2017', 'The House;2017', 'Logan Lucky;2017', 'The Emoji Movie;2017', 'Rory Scovel Tries Stand-Up for the First Time;2017', "The Hitman's Bodyguard;2017", 'Self-criticism of a Bourgeois Dog;2017', 'Kingsman: The Golden Circle;2017', 'Ari Shaffir: Double Negative;2017', 'The Nut Job 2: Nutty by Nature;2017', 'Little Boxes;2017', 'Maz Jobrani: Immigrant;2017', 'Lady Bird;2017', 'Paddington 2;2017', 'The Death of Stalin;2017', 'Christina P: Mother Inferior;2017', 'Creep 2;2017', 'A Bad Moms Christmas;2017', "Daddy's Home 2;2017", 'The Disaster Artist;2017', 'Ferdinand;2017', 'Jack Whitehall: At Large;2017', 'Lynne Koplitz: Hormonal Beast;2017', 'Craig Ferguson: Tickle Fight;2017', 'Judd Apatow: The Return;2017', 'Dave Chappelle: Equanimity;2017', 'Dave Chappelle: The Bird Revelation;2017', 'Game Night;2018', 'Isle of Dogs;2018', 'The Clapper;2018', 'Tom Segura: Disgraceful;2018', 'When We First Met;2018', 'Fred Armisen: Standup for Drummers;2018', 'Love, Simon;2018', 'Game Over, Man!;2018', 'Blockers;2018', 'Deadpool 2;2018', 'Sorry to Bother You;2018', 'Ant-Man and the Wasp;2018', 'Mamma Mia: Here We Go Again!;2018', 'Tag;2018', 'The Man Who Killed Don Quixote;2018', 'Boundaries;2018', 'BlacKkKlansman;2018', 'Jeff Ross Roasts the Border;2017', 'Gintama;2017', 'Black Butler: Book of the Atlantic;2017', 'No Game No Life: Zero;2017']

Как сделать, чтобы это была не строка, а список?
  • Вопрос задан
  • 51 просмотр
Решения вопроса 1
SoreMix
@SoreMix Куратор тега Python
yellow
from ast import literal_eval
s = '''["A Dog's Purpose;2017", 'Fist Fight;2017', 'The Lego Batman Movie;2017', 'Jim Gaffigan: Cinco;2017', 'The Big Sick;2017', 'The Boss Baby;2017', 'Bill Burr: Walk Your Way Out;2017', 'Neal Brennan: 3 Mics;2017', 'Dave Chappelle: The Age of Spin;2017', 'CHiPS;2017', 'Table 19;2017', 'Dave Chappelle: Deep in the Heart of Texas;2017', 'Baywatch;2017', 'Snatched;2017', 'Sandy Wexler;2017', 'Win It All;2017', 'Captain Underpants: The First Epic Movie;2017', 'Cars 3;2017', 'Rough Night;2017', 'Despicable Me 3;2017', 'The Meyerowitz Stories;2017', 'War Machine;2017', 'Vir Das: Abroad Understanding;2017', "Norm Macdonald: Hitler's Dog, Gossip & Trickery;2017", 'Goon: Last of the Enforcers;2017', 'Oh, Hello: On Broadway;2017', 'The House;2017', 'Logan Lucky;2017', 'The Emoji Movie;2017', 'Rory Scovel Tries Stand-Up for the First Time;2017', "The Hitman's Bodyguard;2017", 'Self-criticism of a Bourgeois Dog;2017', 'Kingsman: The Golden Circle;2017', 'Ari Shaffir: Double Negative;2017', 'The Nut Job 2: Nutty by Nature;2017', 'Little Boxes;2017', 'Maz Jobrani: Immigrant;2017', 'Lady Bird;2017', 'Paddington 2;2017', 'The Death of Stalin;2017', 'Christina P: Mother Inferior;2017', 'Creep 2;2017', 'A Bad Moms Christmas;2017', "Daddy's Home 2;2017", 'The Disaster Artist;2017', 'Ferdinand;2017', 'Jack Whitehall: At Large;2017', 'Lynne Koplitz: Hormonal Beast;2017', 'Craig Ferguson: Tickle Fight;2017', 'Judd Apatow: The Return;2017', 'Dave Chappelle: Equanimity;2017', 'Dave Chappelle: The Bird Revelation;2017', 'Game Night;2018', 'Isle of Dogs;2018', 'The Clapper;2018', 'Tom Segura: Disgraceful;2018', 'When We First Met;2018', 'Fred Armisen: Standup for Drummers;2018', 'Love, Simon;2018', 'Game Over, Man!;2018', 'Blockers;2018', 'Deadpool 2;2018', 'Sorry to Bother You;2018', 'Ant-Man and the Wasp;2018', 'Mamma Mia: Here We Go Again!;2018', 'Tag;2018', 'The Man Who Killed Don Quixote;2018', 'Boundaries;2018', 'BlacKkKlansman;2018', 'Jeff Ross Roasts the Border;2017', 'Gintama;2017', 'Black Butler: Book of the Atlantic;2017', 'No Game No Life: Zero;2017']'''
s = literal_eval(s)
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы