Kafka-python KafkaProducer __init__ 采用 1 个位置参数,但给出了 2 个
Kafka-python KafkaProducer __init__ takes 1 positional argument but 2 were given
我遇到以下错误:
Traceback (most recent call last):
connection = KafkaProducer(kafka_settings['topic'], bootstrap_servers=kafka_settings['bootstrap_servers'])
TypeError: __init__() takes 1 positional argument but 2 were given
这对我来说很奇怪,因为我遵循了给定的文档。 https://kafka-python.readthedocs.io/en/master/usage.html
我该如何解决这个问题?
https://kafka-python.readthedocs.io/en/master/usage.html建议bootstrap_servers
是在创建KafkaProducer
时给的参数,但是使用.send
方法时需要指定主题,请尝试以下
connection = KafkaProducer(bootstrap_servers=kafka_settings['bootstrap_servers'])
future = connection.send(kafka_settings['topic'], b'your_message_here')
我遇到以下错误:
Traceback (most recent call last):
connection = KafkaProducer(kafka_settings['topic'], bootstrap_servers=kafka_settings['bootstrap_servers'])
TypeError: __init__() takes 1 positional argument but 2 were given
这对我来说很奇怪,因为我遵循了给定的文档。 https://kafka-python.readthedocs.io/en/master/usage.html
我该如何解决这个问题?
https://kafka-python.readthedocs.io/en/master/usage.html建议bootstrap_servers
是在创建KafkaProducer
时给的参数,但是使用.send
方法时需要指定主题,请尝试以下
connection = KafkaProducer(bootstrap_servers=kafka_settings['bootstrap_servers'])
future = connection.send(kafka_settings['topic'], b'your_message_here')