dimanche 29 novembre 2015

Variable name error in python 3

In my python 3 program for web scraping, searching, showing the date, and timers, there was a syntax error for a variable name. It's named LISA. Here's the code:

import urllib
import time
import json
import urllib.request, urllib.parse
while 1:
    def input1():
        main_input = input('LISA, ')

    def sinput():   
        search_input = input('LISA, search ')


    def tinput():  
         timer_input = input('LISA, timer for ')




def showsome(search_input): 
      query = urllib.parse.urlencode({'q': search_input})
      url = 'http://ift.tt/NaLSBv' % query
      search_response = urllib.request.urlopen(url)
      search_results = search_response.read().decode("utf8")
      results = json.loads(search_results)
     data = results['responseData']
      print('Total results: %s' % data['cursor']['estimatedResultCount'])
      hits = data['results']
      print('Top %d hits:' % len(hits))
      for h in hits: print(' ', h['url'])
      print('For more results, see %s' % data['cursor']['moreResultsUrl'])


def timer(timer_input): 
    timer_input = int(timer_input)
    for x in range(1, timer_input):
        t = 0
        t = t+1
        time.sleep(1)
        print(t)
        if t == timer_input: {
            print('TIMER DONE!!!!!!!')
            }




 def calender():  
     print(time.asctime())


input1()
    if main_input == 'search': {
        sinput()
        showsome(search_input)
        }
    elif main_input == 'timer': {
        tinput()
        timer(timer_input)
        }
    elif main_input == 'calendar': {
        calendar()
        }

It seems like the problem is the url variable when i run it, but there are a couple other errors. Please reply quickly because i am releasing the program on Christmas Eve.




Aucun commentaire:

Enregistrer un commentaire