Я играю с pokebase a python wrapper для pokeAPI, и некоторые ответы api содержат \n
\x0c
et c. В конце концов, они мне не нужны, но я не хочу просто l oop через каждую букву, чтобы удалить их, и .replace тоже не кажется устойчивым (также, потому что я думаю, что это приведет к проблемам).
Это примерный список строк: https://pastebin.com/SbhR50br
["The female's horn\ndevelops slowly.\nPrefers physical\x0cattacks such as\nclawing and\nbiting.", 'When resting deep\nin its burrow, its\nthorns always\x0cretract.\nThis is proof that\nit is relaxed.', 'When feeding its\nyoung, it first\nchews and tender\xad\x0cizes the food,\nthen spits it out\nfor the offspring.', 'It has a calm and\ncaring nature.\nBecause its horn\x0cgrows slowly, it\nprefers not to\nfight.', 'It has a docile\nnature. If it is\nthreatened with\x0cattack, it raises\nthe barbs that are\nall over its body.', 'When NIDORINA are with their friends or\nfamily, they keep their barbs tucked\naway to prevent hurting each other.\x0cThis POKéMON appears to become\nnervous if separated from the others.', 'When it is with its friends or\nfamily, its barbs are tucked away to\nprevent injury. It appears to become\nnervous if separated from the others.', 'The female has a gentle temperament.\nIt emits ultrasonic cries that have the\npower to befuddle foes.', 'The female’s horns develop slowly.\nPrefers physical attacks such as clawing\nand biting.', 'When it senses danger, it raises\nall the barbs on its body. These\nbarbs grow slower than NIDORINO’s.', 'When feeding its young, it first\nchews the food into a paste, then\nspits it out for the offspring.', 'It has a calm and caring nature.\nBecause its horn grows slowly, it\nprefers not to fight.', 'When it senses danger, it raises\nall the barbs on its body. These\nbarbs grow slower than Nidorino’s.', 'The female has a gentle temperament.\nIt emits ultrasonic cries that have the power\nto befuddle foes.', 'When feeding its young, it first chews the food into\na paste, then spits it out for the offspring.', 'When Nidorina are with their friends or family, they keep their\nbarbs tucked away to prevent hurting each other.\nThis Pokémon appears to become nervous if separated from\nthe others.', 'When Nidorina are with their friends or family, they keep\ntheir barbs tucked away to prevent hurting each other.\nThis Pokémon appears to become nervous if separated\nfrom the others.']
flavor = random.choice([listofstringshere])
#remove \ stuff from flavor here!
print(flavor)
Я думаю, что смогу что-то сделать с regex
, но это всего лишь предположение.