yaml.scanner.ScannerError:此处不允许映射值

时间:2020-02-14 06:08:17

标签: python yaml

以下是我的YAML文件:

censorship:    
    settings:      
        blocked:
            words:
                - shit
            nicknames: []

虽然我尝试使用以下代码访问被屏蔽的单词:

    async def on_message(self, message: discord.Message):
        message_guild = message.guild

        def get_censored_words():
            with open(f'configurations/{message_guild.id}_config.yaml', 'r') as censored_words:
                accessor = yaml.safe_load(censored_words)

                list_of_censored_words = accessor['plugins']['censorship']['setting']['blocked']['words']

            return list_of_censored_words

        censored_word = get_censored_words()

        for word in censored_word:
            if str(message).count(word) > 1:
                await message.delete()
                await message.channel.send("Blacklisted word!")
            else:
                continue

由于某种原因,它引发了yaml.scanner.ScannerError: mapping values are not allowed here。我在这里做错了什么?

0 个答案:

没有答案
相关问题