0
Je suit le format des données:Trouver la phrase et le paragraphe avec Python
[1956, Jon's story, He sold his soul in 1987, 200]
[1960, Mary's story, "She liked her soul, but decided to sold it anyway.", 250]
[1963, "Alice and Peter story, with a twist", "Peter said "Your soul is mine!" and tried to sold it, but Alice had no soul and killed him.", 500]
Je veux partager ce à
[1956, 1960, 1963]
['Jon's story', 'Mary's story','Alice and Peter story, with a twist']
['He sold his soul in 1987','She liked her soul, but decided to sold it anyway.','Peter said "Your soul is mine!" and tried to sold it, but Alice had no soul and killed him.']
[200,250,500]
Jusqu'à présent, je l'ai fait
import re
data = [[1956, "Jon's story", "He sold his soul in 1987", 200],
[1960, "Mary's story", "She liked her soul, but decided to sold it anyway.", 250],
[1963, "Alice and Peter story, with a twist", "Peter said 'Your soul is mine!' and tried to sold it, but Alice had no soul and killed him.", 500]]
for row in data:
line = str(row)
sentence = re.split(r',', line)
Mais de cette façon, il prend en compte la séparation des virgules à l'intérieur de "". Comment puis-je l'éviter?
Vous êtes après 'list (zip (* data))'? –
À partir de votre question, je pourrais déduire que vous voulez que chaque premier, deuxième, troisième et quatrième élément de chaque liste retournée en tant que 4 listes distinctes. Est-ce une hypothèse juste? – BoboDarph
Oui, c'est vrai. Les éléments sont séparés par une virgule et "". –