1

I want to print the last response from my GET request using Grinder, here is my code:

response_string = httpUtilities.getLastResponse().getText()
print str(response_string)

I got exception:

 'ascii' codec can't encode character u'\ufffd' in position 
  1: ordinal not in range(128) at this line : 

    print str(response_string)

My question is how to convert java.lang.String .

I got from httpUtilities.getLastResponse().getText() into python string? Response has charset='utf-8'

BugsBunny
  • 99
  • 1
  • 9

2 Answers2

1

No conversion should be required. Change

    print str(response_string)

to

    print response_string
Travis Bear
  • 13,039
  • 7
  • 42
  • 51
1

I had got the exact same error.. Here's a tweak for this kind of response..

try:
   safe_str = response_string.encode('ascii', 'ignore')
   print("text: "+safe_str)

This will definitely work. :)

kirti
  • 40
  • 5