Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.walk()
- <Product Type="Voice">
- <Продукт Тип="Голос">
- file = open('путь к 2.xml', encoding='utf8')
- soup = BeautifulSoup(file, 'html.parser')
- try:
- file_type = soup.find('Product')['Type']
- except:
- file_type = soup.find('Продукт')['Тип']
- soup = BeautifulSoup(file, 'xml')
- try:
- file_type = soup.find('Product')['Type']
- except:
- file_type = soup.find('Продукт')['Тип']
- print(file_type) # Голос
- <Продукты>
- <Продукт Тип="Голос"/>
- <Продукт Тип="Голос"/>
- <Продукт Тип="Голос"/>
- <Продукт Тип="Голос"/>
- </Продукты>
- pip install lxml
Add Comment
Please, Sign In to add comment