Почему это работает:
def clean(text: str):
return text \
.replace('?', '') \
.replace("|", '') \
.replace('\"', '') \
.replace(' ', '') \
.replace(':', '') \
.replace('\\', '') \
.replace('/', '') \
.replace('>', '') \
.replace('<', '') \
.replace('"', '') \
.replace('+', '') \
.replace('*', '') \
.replace(' .', '')
...
class ParseText:
...
def save_text(self):
part = open('src/text/{}.txt'.format(clean(partName)), 'w', encoding="utf-8")
А это не работает:
def clean(text: str):
strings = ['?', "|", '\"', ]
result = (text.replace(i, "") for i in strings)
result = str()
for i in strings:
print(i)
result = text.replace(i, '')
continue
return result
...
class ParseText:
...
def save_text(self):
part = open('src/text/{}.txt'.format(clean(partName)), 'w', encoding="utf-8")