Guest User

Untitled

a guest
Nov 19th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. os.walk()
  2.  
  3. <Product Type="Voice">
  4.  
  5. <Продукт Тип="Голос">
  6.  
  7. file = open('путь к 2.xml', encoding='utf8')
  8. soup = BeautifulSoup(file, 'html.parser')
  9. try:
  10. file_type = soup.find('Product')['Type']
  11. except:
  12. file_type = soup.find('Продукт')['Тип']
  13.  
  14. soup = BeautifulSoup(file, 'xml')
  15.  
  16. try:
  17. file_type = soup.find('Product')['Type']
  18. except:
  19. file_type = soup.find('Продукт')['Тип']
  20.  
  21. print(file_type) # Голос
  22.  
  23. <Продукты>
  24. <Продукт Тип="Голос"/>
  25. <Продукт Тип="Голос"/>
  26. <Продукт Тип="Голос"/>
  27. <Продукт Тип="Голос"/>
  28. </Продукты>
  29.  
  30. pip install lxml
Add Comment
Please, Sign In to add comment