0
標籤的整數值,我想恢復標籤蟒蛇檢索與minidom命名
from xml.dom import minidom
docXML = minidom.parse('/root/Desktop/doc.xml')
node = docXML.getElementsByTagName('span')[0]
value = node.firstChild.data
" return value is 5.22%"
str1 = value.split('%')
"return [u'\n5.22', u'\n']"
finalvalue = ''.join(str1)
"return 5.22"
的整數值,但如果我想這串字符
convert = int(finalvalue)
我有以下錯誤轉換
"ValueError invalid literal for int() with base 10: '5.22 ' "
當我使用split方法我得到以下結果:
[u'\n5.22', u'\n']
非常感謝bro.you是我的救命恩人^^ – user3710113