Andrew
Andrew

Reputation: 12422

Strings are wrapped in b'...'

import urllib.request

#name = input("What is your screenname? ");
name = "zezima"
page = urllib.request.urlopen('http://hiscore.runescape.com/index_lite.ws?player=' + name)
page = page.readlines()

skills = []
for line in page:
  skills += [line]



print(skills)

Outputs:

[[b'478,2372,1224928266\n'], [b'458,99,59502162\n'], [b'262,99,56673986\n'], [b'1355,99,39565273\n'], [b'227,99,61315106\n'], [b'260,99,37119213\n'], [b'502,99,14155051\n'], [b'27,99,63829007\n'], [b'5,99,200000000\n'], [b'2084,99,22203776\n'], [b'60,99,113793712\n'], [b'567,99,27240251\n'], [b'26,99,117368919\n'], [b'259,99,18094553\n'], [b'172,99,17565654\n'], [b'727,99,15789879\n'], [b'8,99,57473883\n'], [b'1420,99,13592712\n'], [b'5,99,200000000\n'], [b'640,99,18641664\n'], [b'413,99,19465433\n'], [b'745,99,16113397\n'], [b'7540,99,13187561\n'], [b'708,99,13229510\n'], [b'6230,95,9007564\n'], [b'2724,1944\n'], [b'-1,-1\n'], [b'-1,-1\n'], [b'-1,-1\n'], [b'-1,-1\n']]

I was wondering why each item in the list above has a b in front of it.

Shouldn't the list look like this?:

[['478,2372,1224928266\n'], ['458,99,59502162\n'], ['262,99,56673986\n']...]

Upvotes: 1

Views: 598

Answers (1)

Li0liQ
Li0liQ

Reputation: 11264

"b" means byte array. You can refer to this question for a solution.

Upvotes: 6

Related Questions