Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to climb the phonetic alphabet with Python

Shulou Source: shulou.com Published: 2022-06-02 08:30:04 10月04日 Update

This article mainly explains "how to use Python to climb the phonetic alphabet". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to climb the phonetic alphabet with Python".

#-*-coding: UTF-8-*-import requestsimport timefrom bs4 import BeautifulSoupf = open ('. / words.txt') fw = open ('. / result.txt','a') line = f.readline () index = 0while line: index = index+1 url = "https://www.oxfordlearnersdictionaries.com/definition/english/" + line.strip () print (str (index) +": "+ url) wbdata = requests.get (url,headers= {'User-Agent':' Mozilla/5.0 (Macintosh) Intel Mac OS X 10 / 12 / 1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.75 Safari/537.36'}) .text soup = BeautifulSoup (wbdata) 'html.parser') news_titles = soup.select ("span.pron-g > span.phon") # print (news_titles) result =' 'for n in news_titles: title = n.get_text () if' NAmE' in title: result + ='['+ title.replace ('NAmE',''). Replace (' / /' Print (result) fw.write ((result + "\ n") .encode ("utf-8") line = f.readline () time.sleep (0.1) fw.close () f.close () Thank you for your reading The above is the content of "how to use Python to climb phonetic symbols". After the study of this article, I believe you have a deeper understanding of how to use Python to climb phonetic symbols, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Phonetic alphabet learning content that is ideas situations articles more knowledge knowledge points articles follow questions UTF-8 utf-8 practice push research verification Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Shulou Tech Info Xiaomi Redmi MySQL