Answer the question
In order to leave comments, you need to log in
Expecting value: line 1 column 1 (char 0) with banal json.load()?
here in this piece of code I load json file
def set_mat(id):
global users_mat
if not str(id) in os.listdir('mat/'):
os.mkdir(str('mat/'+str(id)))
with open("mat/" + str(id) + "/users_mat.json", 'w+') as f:
json.dump({'mats':{},'send_time' : {'hour': 9, 'min': 0, 'is_on': 1}, 'last_time':{'day':time.strptime(time.asctime()).tm_yday-1}}, f)
with open("mat/" + str(id) + "/users_mat.json", 'r') as f:
users_mat = json.load(f)
print (str(json.load(f)))
return users_mat
def mat_filter(message): #
def mat_write(message, word):
set_mat(message.chat.id)
for mat in cfg.mat_list:
if mat.lower() in word.lower():
if not str(message.from_user.id) in users_mat['mats'].keys():
with open("mat/" + str(message.chat.id) + "/users_mat.json", 'w+') as f:
users_mat['mats'][str(message.from_user.id)] = 0
json.dump(users_mat, f)
with open("mat/" + str(message.chat.id) + "/users_mat.json", 'w+') as f:
users_mat['mats'][str(message.from_user.id)] = users_mat['mats'][str(message.from_user.id)] + 1
json.dump(users_mat, f)
wordm = ''
x = 0
for i in message.text:
x += 1
if x == len(message.text):
mat_write(message, wordm)
wordm = ''
break
if i == '\n':
continue
if i != ' ':
wordm += i
else:
mat_write(message, wordm)
wordm = ''
I call the mat_filter function, which in turn calls set_mat , inside which I create a jane file of the format {'hour': 9, 'min': 0, 'is_on': 1}, 'last_time':{'day':time .strptime(time.asctime()).tm_yday-1}} , and then I read it but when reading (json.load()) an error occurs: Answer the question
In order to leave comments, you need to log in
users_mat = json.load(f)
print (str(json.load(f)))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question