讓這個函式動起來
太棒了!你看到 f-strings 的速度與方便後超興奮,因此打算重構更多舊程式碼。
現在你知道,f-strings 可以在字串中直接評估運算式,還能呼叫函式與方法。你決定把它們用在一個專案裡:分析 120 則推文,檢查是否包含不同新聞的連結。這樣一來,你預期程式碼會更乾淨、也更易讀。
變數 number1、number2、string1 和 list_links 已經預先載入。
如果想先查看變數內容,你可以在 IPython Shell 中用 print() 來檢視。
本練習屬於課程
Python 中的正規表示法
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Include both variables and the result of dividing them
print(f"___ tweets were downloaded in ____ minutes indicating a speed of ____ tweets per min")