timmy / Python 字串格式化
0 Favoriten
0 Forks
1 Dateien
Zuletzt aktiv 9 months ago
Python 提供多種字串格式化方法,f-string(Python 3.6+)更直觀且效能較佳,而 str.format() 適用於較舊版本。這些方法常用於動態組合字串,如建立 URL、日誌輸出或命令構造。
| 1 | url = f"http://localhost:{args.port}" |
| 2 | |
| 3 | url = "http://localhost:{}".format(args.port) |
Neuer
Älter