簡體   English   中英

格式化 output 只包含 email

[英]Format output to only include email

完全菜鳥問題 IK 我需要刪除“mailto:”我只希望返回 [holtp@moval.edu]

def email_lookup(url):
    url_open =requests.get(url)
    soup = BeautifulSoup(url_open._content, 'html.parser')
    for link in soup.find_all('a',{'class':'email'}):
        print(link.get('href'))
    

輸出:

[郵箱:holtp@moval.edu]

一種簡單的方法是使用替換 function:

link = link.replace("mailto:", "")

您可以使用replace(string_to_replace, new_string) function 來替換您想要的 substring。

因此,您可以使用以下代碼片段:

string.replace('mailto:', '')

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM