I have a Python Project . which is not working. Please assit me on these codes I
ID: 3889553 • Letter: I
Question
I have a Python Project . which is not working. Please assit me on these codes
Im getting these errors
in <module>
betterResult = result.json()
File "C:Usersmash4AppDataLocalProgramsPythonPython36-32libsite-packages equestsmodels.py", line 892, in json
return complexjson.loads(self.text, **kwargs)
File "C:Usersmash4AppDataLocalProgramsPythonPython36-32libjson__init__.py", line 354, in loads
return _default_decoder.decode(s)
File "C:Usersmash4AppDataLocalProgramsPythonPython36-32libjsondecoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:Usersmash4AppDataLocalProgramsPythonPython36-32libjsondecoder.py", line 357, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Explanation / Answer
CODE IS WORKING
import tkinter as tk
from tkinter import ttk
import json
import requests as re
url = "https://twitter.com/search.json?q= 'chine"
#twitter_api = twitter.read_token_file("https://twitter.com/")
class NametFrame(ttk.Frame):
def __init__(self, parent):
ttk.Frame.__init__(self, parent, padding = '10 10 10 10')
self.pack(fill = tk.BOTH, expand = True)
#Define string variable for the entry field
self.fieldname = tk.StringVar()
#Create a label , an ntry field , and a button
ttk.Label(self, text = "Your name : ").grid(column = 0, row = 0, sticky = tk.E)
ttk.Entry(self, width = 25, textvariable = self.fieldname).grid(column = 1, row = 0)
ttk.Button(self, text = "Search", command = self.search).grid(column = 2, row = 0)
#Add padding to all child components
for child in self.winfo_children():
child.grid_configure(padx = 5, pady = 3)
#Define the callback method for clear button
def search(self):
name = self.fieldname.get()
result = re.get(url)
better_result = result.json()
print(len(better_result))
return better_result
if __name__ == '__main__':
root = tk.Tk() #Create the roor window
root.title("Searching your name on Twitter ") #Create frame
NametFrame(root)
root.mainloop()
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.