Jump to content


Chapter 08

  • Please log in to reply
4 replies to this topic

#1 anvesh


    New Member

  • Members
  • Pip
  • 5 posts

Posted 27 March 2013 - 09:51 AM

<Scenario for mobile development>

Its getting a Type Error after selecting athlete name in the dialogue box.

Error msg: Post data should be a byte or iterable of bytes. It cannot be str.

Error message is generating after it executing
json.loads(send_to_server(web_server + get_data_cgi,{'which_athlete': which_athlete}))


Edited by anvesh, 27 March 2013 - 09:55 AM.

#2 anvesh


    New Member

  • Members
  • Pip
  • 5 posts

Posted 28 March 2013 - 04:40 PM

I Cant figure it out what's the problem is?? Can any one tell me what it is???

I am stuck with this problem from past 4 days and now no idea what to do..

I tried googling and right now i'm nowhere...............

Please help me .....

Edited by anvesh, 28 March 2013 - 04:40 PM.

#3 anvesh


    New Member

  • Members
  • Pip
  • 5 posts

Posted 02 April 2013 - 07:15 AM

Why the hell no one is helping me.....

i'm still stuck with this problem i couldnt able to solve....

please ask what ever details u people want......
Note: Please check attachment, IT's Not type error of index mentioned in text book..

I'm stuck with this problem from past 1 month and i am nowhere of learning the python...

Plz help me...

Edited by anvesh, 02 April 2013 - 07:19 AM.

#4 paulbarry


    Advanced Member

  • O'Reilly Author
  • PipPipPipPipPipPipPipPip
  • 307 posts

Posted 16 April 2013 - 05:03 AM

Plz help me...

Dear anvesh.

Sorry you are having so much trouble, and also sorry for the delay in replying (I've been unable to check this forum for a while).

It looks like you are using a version of Python for Android (v3?) other than the one used in the book. The Py3k4a webpage describes their software as "beta", which you should read as an indication that it is not yet ready for prime-time.

Other readers have had similar problems with using versions of SL4A and Py4A that differ from the book. All of their problems went away whenever they matched the downloads and versions exactly to those in the book.

Unfortunately, I'm not in a position to try out the versions you are using myself. But, what's in the book does work.



#5 lyr520


    New Member

  • Members
  • Pip
  • 1 posts

Posted 11 May 2013 - 02:38 AM

I have the same problem,but i have solved.
I use Python3forAndroid.
The modified code is as follows:

import android
import json
import time
import sys
from urllib.request import urlopen     #python3
from urllib.parse import urlencode    #python3

hello_msg     = "Welcome to Coach Kelly's Timing App"
list_title    = 'Here is your list of athletes:'
quit_msg      = "Quitting Coach Kelly's App."

web_server    = ''

get_names_cgi = '/cgi-bin/generate_names.py'
get_data_cgi  = '/cgi-bin/generate_data.py'

def send_to_server(url, post_data=None):
    if post_data:
        page = urlopen(url, urlencode(post_data).encode())   #python3
        page = urlopen(url)


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users