-
當(dāng)前位置:首頁 > 創(chuàng)意學(xué)院 > 技術(shù) > 專題列表 > 正文
html與python交互(html與python結(jié)合)
大家好!今天讓創(chuàng)意嶺的小編來大家介紹下關(guān)于html與python交互的問題,以下是小編對此問題的歸納整理,讓我們一起來看看吧。
ChatGPT國內(nèi)免費在線使用,一鍵生成原創(chuàng)文章、方案、文案、工作計劃、工作報告、論文、代碼、作文、做題和對話答疑等等
只需要輸入關(guān)鍵詞,就能返回你想要的內(nèi)容,越精準(zhǔn),寫出的就越詳細(xì),有微信小程序端、在線網(wǎng)頁版、PC客戶端
官網(wǎng):https://ai.de1919.com
本文目錄:
一、如何用Python做HTML的頁面
<html>
<body>
<form>
可獲取碼列表:
<select name="liscode">
<option value="01">123456</option>
<option value="02">123457</option>
<option value="03">123458</option>
<option value="04">123459</option>
<option value="05">123460</option>
<option value="06">123461</option>
</select>
<input type="submit" value="確認(rèn)獲取"/>
</form>
</body>
</html>
其中所有l(wèi)iscode是從一個txt文檔上提取的,當(dāng)用戶點擊獲取一個的時候,該項即被刪除。
如何用python實現(xiàn)呢?
做一個py腳本或exe給用戶實現(xiàn)的話大概像下面這樣:
Python code
infile = open('codelist.txt','r') codelist = infile.readlines() used_code = codelist[0] #remove用掉的code(刪除行) codelist.remove(codelist[0]) infile.close() #重寫文件(我不知道是否有能直接刪除一行的文件操作方法) outfile = open('codelist.txt','w') for code in codelist: outfile.write(code + '\n') outfile.close() print used_code
二、發(fā)送HTML電子郵件與Python問題,怎么解決
#!/usr/bin/env pythonimport smtplibfrom email.mime.multipart import MIMEMultipartfrom email.mime.text import MIMEText# me == my email address# you == recipient's email addressme = "my@email.com"you = "your@email.com"# Create message container - the correct MIME type is multipart/alternative.msg = MIMEMultipart('alternative')msg['Subject'] = "Link"msg['From'] = memsg['To'] = you# Create the body of the message (a plain-text and an HTML version).text = "Hi!nHow are you?nHere is the link you wanted:nhttp://www.python.org"html = """
<html>
<head></head>
<body>
<p>Hi!<br>
How are you?<br>
Here is the <a href="http://www.python.org">link</a> you wanted.
</p>
</body></html>"""
# Record the MIME types of both parts - text/plain and text/html.
part1 = MIMEText(text, 'plain')
part2 = MIMEText(html, 'html')
# Attach parts into message container.
# According to RFC 2046, the last part of a multipart message, in this case
# the HTML message, is best and preferred.
msg.attach(part1)
msg.attach(part2)
# Send the message via local SMTP server.
s = smtplib.SMTP('localhost')
# sendmail function takes 3 arguments: sender's address, recipient's address
# and message to send - here it is sent as one string.
s.sendmail(me, you, msg.as_string())
s.quit()
三、如何用Python做HTML的頁面
<html>
<body>
<form>
可獲取碼列表:
<select name="liscode">
<option value="01">123456</option>
<option value="02">123457</option>
<option value="03">123458</option>
<option value="04">123459</option>
<option value="05">123460</option>
<option value="06">123461</option>
</select>
<input type="submit" value="確認(rèn)獲取"/>
</form>
</body>
</html>
其中所有l(wèi)iscode是從一個txt文檔上提取的,當(dāng)用戶點擊獲取一個的時候,該項即被刪除。
如何用python實現(xiàn)呢?
做一個py腳本或exe給用戶實現(xiàn)的話大概像下面這樣:
Python code
infile = open('codelist.txt','r') codelist = infile.readlines() used_code = codelist[0] #remove用掉的code(刪除行) codelist.remove(codelist[0]) infile.close() #重寫文件(我不知道是否有能直接刪除一行的文件操作方法) outfile = open('codelist.txt','w') for code in codelist: outfile.write(code + '\n') outfile.close() print used_code
四、如何用Python做HTML的頁面
<html>
<body>
<form>
可獲取碼列表:
<select name="liscode">
<option value="01">123456</option>
<option value="02">123457</option>
<option value="03">123458</option>
<option value="04">123459</option>
<option value="05">123460</option>
<option value="06">123461</option>
</select>
<input type="submit" value="確認(rèn)獲取"/>
</form>
</body>
</html>
其中所有l(wèi)iscode是從一個txt文檔上提取的,當(dāng)用戶點擊獲取一個的時候,該項即被刪除。
如何用python實現(xiàn)呢?
做一個py腳本或exe給用戶實現(xiàn)的話大概像下面這樣:
Python code
infile = open('codelist.txt','r') codelist = infile.readlines() used_code = codelist[0] #remove用掉的code(刪除行) codelist.remove(codelist[0]) infile.close() #重寫文件(我不知道是否有能直接刪除一行的文件操作方法) outfile = open('codelist.txt','w') for code in codelist: outfile.write(code + '\n') outfile.close() print used_code
以上就是關(guān)于html與python交互相關(guān)問題的回答。希望能幫到你,如有更多相關(guān)問題,您也可以聯(lián)系我們的客服進(jìn)行咨詢,客服也會為您講解更多精彩的知識和內(nèi)容。
推薦閱讀:
html網(wǎng)頁制作(html網(wǎng)頁制作代碼大全)