from bs4 import beautifulsoup
text='''
<?xml version="1.0" encoding="iso-8859-1"?>
harry potter
29.9
learning xml
39.95
'''soup=beautifulsoup(text)
#按標準輸出
# print(soup.prettify)
#獲取所有文字
# print(soup.get_text())
#tag 物件
tag=soup.title
# print(tag)
tag.name #標籤name
tag.attrs #標籤屬性
tag['lang'] #某一屬性
tag.string #獲取文字
string='
'sp=beautifulsoup(string)
# sp.p.string
# print(soup.find_all('title',))
# print(soup.find('title',lang='eng'))
# soup.book
# soup.book.contents
# for child in soup.book.children: #字節點
# print(child)
# for parent in soup.book.parent: #父節點
# print(parent)
# for parents in soup.book.parents: #所有父節點
# print(parents.name)
soup.title.next_sibling #下乙個兄弟
soup.title.previous_sibling #上乙個兄弟
for sibling in soup.title.next_siblings: #所有兄弟
print(sibling)
四大元件(四) content provider
content provider相當於是程式與程式之間的介面。讓原本不可能通訊的程式,通過內容提供者這個橋梁變得可以通訊。定義乙個類 繼承 contentprovider public class backdoor extends contentprovider 註冊contentprovider ...
C 四大演算法
氣泡排序 using system namespace bubblesorter j public class mainclass bubblesorter sh new bubblesorter sh.sort iarrary for int m 0 m iarrary.length m cons...
android 四大元件
1.activity 2.service 3.contentprovider 應用中的資料,對外進行共享,其它應用可以通過內容提供者,可以訪問到你應用中的資料,對資料進行增刪改查 1 對不同的資料格式,統一了檔案格式和資料訪問api 2 內容提供者要繼承contentprovider類 3 在清單檔...