所以我一直在試圖格式化從CL拍攝網頁,以便我可以將它發送到我的郵箱, 但是這是我想出每次我嘗試任何事情,除去\n
和\t
無法刪除python3字符串中的 n和 t?
b'\n\n\n\t\n\t\n\t\n\t\n\t\n\t\n\n\n\n\t\n\n\n\t
\n\t\t\t
\n\t
\n\t\t
\n\t\t\t
\n 0 favorites\n
\n\n\t\t
\n\t\t
∨
\n\t\t
∧
\n\t\t
\n \n
\n
\n\t \tCL wenatchee all personals casual encounters\n
\n
\n\t\t
\n\t
\n
\n\n\t\t
\n\t\t\t
\n\t\n\t\t\n\t\n\n\n\nReply to: [email protected]\n
\n\n\n\t
\n\t\n\t\tflag [?] :\n\t\t\n\t\t\tmiscategorized\n\t\t\n\t\t\tprohibited\n\t\t\n\t\t\tspam\n\t\t\n\t\t\tbest of\n\t\n
\n\n\t\t
Posted: 2013-08-28, 8:23AM PDT
\n
\n\n
\n \n Well... - w4m - 22 (Wenatchee)\n
我時間已經試過剝離,替換,甚至正則表達式,但沒有任何事情,它總是出現在我的電子郵件不受任何事情影響。
下面的代碼:
try:
if url.find('http://') == -1:
url = 'http://wenatchee.craigslist.org' + url
html = urlopen(url).read()
html = str(html)
html = re.sub('\s+',' ', html)
print(html)
part2 = MIMEText(html, 'html')
msg.attach(part2)
s = smtplib.SMTP('localhost')
s.sendmail(me, you, msg.as_string())
s.quit()
此代碼不會運行,您的文章實際上沒有格式化。格式化您的問題,併發佈一個[簡短,自包含的示例](http://sscce.org/),我們可以複製和粘貼以重現您的問題,否則您不可能獲得任何幫助。 –