2009-12-04 66 views
1
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「...」

[[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']...] 
+0

哪個python? 3.X?請指定版本。 – 2009-12-04 00:23:23

回答

6

「B」 表示字節數組。 您可以參考this問題獲取解決方案。

相關問題