Кто-нибудь из вас знает, как изменить python2 (str) байтовую строку на Unicode python3?
Вот мой код:
def scan_ip_worker(self):
recheck_ip = False
while self.scan_thread_count <= self.scan_ip_thread_num and self.running:
time.sleep(1)
try:
# work for idle and too many scan failures
if (recheck_ip or \
self.scan_ip_thread_num == 1 and \
self.config.max_scan_ip_thread_num > 1) and \
self.check_local_network.is_ok():
if self.good_ip_num >= self.max_good_ip_num * 0.6 and \
len(self.ip_list) >= self.max_good_ip_num * 0.9:
ip_str = self.get_ip(to_recheck=True)
if ip_str and self.check_local_network.is_ok(ip_str):
self.recheck_ip(ip_str, first_report=False)
time.sleep(self.scan_recheck_interval)
continue
else:
self.adjust_scan_thread_num()
except Exception as e:
self.logger.exception("scan_ip_worker recheck ip except:%r", e)
finally:
recheck_ip = False
try:
ip_str = self.ip_source.get_ip()
# self.logger.debug("check ip:%s", ip)
if not ip_str or ip_str in self.ip_dict:
time.sleep(5)
continue
if not self.check_local_network.is_ok(ip_str):
# self.logger.debug("scan_ip:%s network is fail", ip)
time.sleep(5)
result = self.check_ip(ip_str)
Но это дает мне ошибка:
scan_ip_worker, за исключением: TypeError ("'in' требует строку как левый операнд, а не байты")