我只学习了Python的基础知识请原谅我,但我无法确定其他帖子的修复.我用'r'打开我的JSON文件,我想我正在写它们但是它不喜欢它.将其更改为'r'无济于事:(
对于以下部分:
if isinstance(to_write, list):
self.log_file.write(''.join(to_write) + "<r/>")
else:
self.log_file.write(str(to_write) + "<r/>")
self.log_file.flush()
Run Code Online (Sandbox Code Playgroud)
我得到的错误是: a bytes-like object is required, not 'str'
import math
import time
from random import randint
import json
from instagram.client import InstagramAPI
class Bot:
def __init__(self, config_file, tags_file):
# Loading the configuration file, it has the access_token, user_id and others configs
self.config = json.load(config_file)
# Loading the tags file, it will be keep up to date while the script is running
self.tags = json.load(tags_file)
# Log file …Run Code Online (Sandbox Code Playgroud)