首页 > 解决方案 > python3 bot的问题:ValueError:int()的无效文字,基数为10:''

问题描述

运行 python3 机器人时,我收到以下错误:

ValueError: int() 以 10 为底的无效文字:''

一直在查看 main.py 以尝试查看问题出在哪里,但没有运气。我承认我缺乏经验,只是想学习一些新东西,任何帮助将不胜感激。

以下是错误:

wirng@localhost:~/bot# python3 main.py
Traceback (most recent call last):
  File "main.py", line 1133, in <module>
    client = BotClient(max_messages=10)
  File "main.py", line 274, in __init__
    self.config = Config()
  File "main.py", line 133, in __init__
    self.patreon_server = int(config.get('DEFAULT', 'patreon_server'))
ValueError: invalid literal for int() with base 10: ''

我不确定错误来自哪里,但我认为它来自这部分代码:

self.patreon = config.get('DEFAULT', 'patreon_enabled') == 'yes'
self.patreon_server = int(config.get('DEFAULT', 'patreon_server'))

if self.patreon:
    logger.info('Patreon is enabled. Will look for servers {}'.format(self.patreon_server))

标签: python-3.x

解决方案


推荐阅读