#Python TQC考題902 資料加總
f=open(“read.txt”,”r”,enconding=”utf-8″)
data=f.read()
L=[int(i) for i in data.split()]
print(sum(L))
f.close()

“””
read.txt的內容:
1 2 3 6 3
(加總=15)
“””

#多印一些資料,了解程式運作:
#read.txt內容: 1 4 2 3 (加總10)

#用.readline()也可以

#少encoding=”utf-8″ 也行

“””
TQC txt檔的資料為:
11 22 33 22 33 44 33 44 55 44 55 66 55 66 77
雖然簡單,但還是可能使用
.append(line.split())
做成list中還有list
“””


![Python如何串接OpenAI /Claude /Gemini API自動將大量維修紀錄JSON轉自然語言描述(並避免中斷資料遺失)response = client.chat.completions.create() ; reply = response.choices[0].message.content Python如何串接OpenAI /Claude /Gemini API自動將大量維修紀錄JSON轉自然語言描述(並避免中斷資料遺失)response = client.chat.completions.create() ; reply = response.choices[0].message.content](https://i0.wp.com/savingking.com.tw/wp-content/uploads/2025/07/20250716084059_0_c5b368.png?quality=90&zoom=2&ssl=1&resize=350%2C233)






![使用 Python 檢驗字符串格式:掌握正則表達式(Regular Expression)的起始^與終止$符號, pattern = r’^GATR[0-9]{4}$’ 使用 Python 檢驗字符串格式:掌握正則表達式(Regular Expression)的起始^與終止$符號, pattern = r’^GATR[0-9]{4}$’](https://i1.wp.com/savingking.com.tw/wp-content/uploads/2024/07/20240712093637_0.png?quality=90&zoom=2&ssl=1&resize=350%2C233)


近期留言