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)


输出:

[[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']]


我想知道为什么上面列表中的每个项目前面都有一个b

列表不应该是这样吗?:

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

最佳答案

“ b”表示字节数组。
您可以参考this问题寻求解决方案。

关于python - 字符串用b'…'包裹,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/1844034/

10-17 02:20