目前分類:Python (2)

瀏覽方式: 標題列表 簡短摘要
import requests
from bs4 import BeautifulSoup
.get("https://www.ptt.cc/bbs/MobileComm")
soup = BeautifulSoup(r.text, "html.parser")
sel = soup.select("div.title a")

for s in sel:
    print(s["href"],s.text)
r = requests
文章標籤

羽 發表在 痞客邦 留言(0) 人氣()

def data_item(check_code):
    if(check_code == 'A'):
        return  "滷肉飯"

    elif(check_code == 'B'):
        return "火鍋"
    elif(check_code == 'C'):
        return  "薯條"

input_value = input("請選擇套餐(A,B,C):")
print("今天我想來點>>>%s" %(data_item(input_value)))
print("隨便來點答案吧")


print(data_item('A'))

前面def 定義data_item裡面的程式

後面縮排 代表執行主程式

文章標籤

羽 發表在 痞客邦 留言(0) 人氣()