我的代碼的具體數據:指定字符串中的響應變量
#Importing the urllib tool to my program
import urllib.request
#Fetch data from URL
response = urllib.request.urlopen('<URL>')
#Store that response into the variable below
taginfo = response.read()
#Tag info result of search for SSI values
taginforesult = taginfo
#print taginfo
print(taginfo)
在Python Shell以上的結果是正確的,如下所示:
b'LOCATE00016331: tagid="00016331", taggroupid=LOCATE, tagtype=mantis04A, irlocator=null, motion=false, tamper=false, panic=false, lowbattery=false, locationzone="", gpsid="", lastgpsid="", lastgpsts=null, confidencebyrule={}\r\n(CarrierHQ_channel_A: reader=CarrierHQ, channel="A", ssi=-95)\r\n(CarrierHQ_channel_B: reader=CarrierHQ, channel="B", ssi=-99)\r\n\r\n\r\n'
我想是知道的是:如何從上述響應中只選擇SSI=-95
和SSI-99
值,然後將它們插入SSI-A
和SSI-B
變量?
我是否strip()
,findall()
,search()
,...?
您提到過哪些想法?結果是什麼? – 2013-11-03 16:13:21