如何将txt文件中的字符串更改为列表格式?

2024-06-28 19:32:40 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个文本文件,如下所示:

[[[SUBMISSION:]]] Calling women ‘Karen’ is starting to become a problem. I’m fully for the mockery and general backlash that those middle aged, usually white, women who demand to speak to the manager and throw huge fits over something senselessly small receive. Even more so if they’re racist or homophobic in the process.   However, I’ve started noticing on social media that women who... just stand up for themselves are being brushed off as a ‘Karen’. I have a female friend who tends to be more active on social media and posts funny jokes or comments to memes on whatever platform she’s using. She gets sexually harassed in pretty gross ways in those comments, and usually it has nothing to do with the joke or post. Just gross comments about sexual stuff they want to do to her, completely unprovoked. So she stands up for herself and gets called a Karen. She even said once she just silently reported the gross comment and STILL got called a Karen for reporting it. When she told our friend group this, more than half the girls chimed in and mentioned that they’d experienced the same thing.   Women are starting to be labeled ‘Karen’ for just setting boundaries or for talking back. It’s becoming less of a way to shame horribly rude racists and homophobes and now a way to tell girls to shut up.   And I know I’ll probably be called a Karen for making this. That’s fine. I know I’m not. It’s not ok to harass women and then when they stand up for themselves compare them to something as horrible as what ‘Karen’ has come to mean. Asking for respect doesn’t make you a Karen.  Edit: this post was intended to be about women in general and wasn’t meant to be a race thing but it seems like that’s what it’s become in a lot of comments. I’ve also learned that every race has their version of the term“Karen”. Thank you for those taking the time to educate. Stereotypes aren’t ok. No matter the race. So while this post was originally about the recent popularity of Karen, it’s just as important to be aware of the same thing happening across all races and be aware of the terms that are used and to SPEAK UP if you see others being put down like that.  Edit: thank you guys for the rewards!! I’m really surprised that this has taken off and I’m trying my best to read every comment you guys leave! Even if you disagree with me I do appreciate your feedback and your point of views. That is, if you type out more than just “ok Karen” lmao

    [[[COMMENT:]]] I had a manager named Karen, she was the sweetest and kindest manager I've ever had. She was always smiling and I adored her. I feel bad for people like her.  Also if I was your friend the next time she gets called a Karen for defending herself from sexual harrassment I would respond with "okay Epstein"

        [[[OP_REPLY:]]] That’s an amazing comeback

    [[[COMMENT:]]] It's gotten so out of hand. I saw a video where a woman was distracting another woman’s service dog (despite the clearly labeled vest) snd she firmly but kindly asked the lady not to distract her working SD. People in the comments were calling her a "Karen” and saying things like she didn’t know better etc. This SD handler was just standing up for herself as distracting a SD can be very dangerous and people were making fun of her calling her a Karen because she doesn’t want her SD to potentially miss performing a life saving act. It’s crazy.

        [[[OP_REPLY:]]] That’s exactly the kind of thing I’m talking about.  Just setting boundaries is making women into “Karens”. It’s a really unhealthy mindset for the next generation of women to be exposed to

    [[[COMMENT:]]] “Karen” has sort of become the new “simp” in that it was once a clever, cheeky diss but is now just a vapid word used to constantly target a large, irrelevant group of people. Genuine Karens are annoying as hell and deserve to be called out for their behavior, but lately I’ve seen the term hurled at practically every woman who isn’t totally spineless.

        [[[OP_REPLY:]]] Exactly ! And same with simp. A man is NOT a simp for bringing his girlfriend flowers or opening the door for his wife. These two terms are equally damaging to our young generations and their future friendships and romantic relationships.

实际的txt文件包含多个提交和注释

我想得到这样的东西:

[['first comment corresponding to submission 1', 'second comment corresponding to submission 1],
 ['first comment corresponding to submission 2', 'second comment corresponding to submission 2', ...], ...]

我如何做到这一点


Tags: andofthetoinyouforthat
1条回答
网友
1楼 · 发布于 2024-06-28 19:32:40

我自己设法解决了这个问题

import re

[re.findall('[[[COMMENT:]]]] (.*)\n\n\t\t', i) for i in data.split("[[[SUBMISSION:]]]")[1:]]

原来是个很简单的问题哈哈哈

相关问题 更多 >