#Python TQC考題907 計算行數,字數,字元數
“””
txt的內容:
What is Python language?
Python is a widely used high-level, general-purpose, interpreted, dynamic programming language.
Its design philosophy emphasizes code readability, and its syntax allows programmers to express concepts in fewer lines of code than possible in languages such as C++ or Java.
Python supports multiple programming paradigms, including object-oriented, imperative and functional programming or procedural styles.
It features a dynamic type system and automatic memory management and has a large and comprehensive standard library.
The best way we learn anything is by practice and exercise questions. We have started this section for those (beginner to intermediate) who are familiar with Python.
“””
# TODO
fname = input() #read.txt
c_line = c_word = c_char = 0
with open(fname,”r”) as file:
for line in file:
c_line += 1
word = line.split()
#print(word,end=” “)
#print(type(word))
c_word += len(word)
c_char += sum([len(x) for x in word])
#print([len(x) for x in word])
#print(“=======================”)
print(“%d line(s)” %c_line)
print(“%d word(s)” %c_word)
print(“%d character(s)” %c_char)
“””
_ line(s)
_ word(s)
_ character(s)
“””

![Python: 如何使用 os.environ[“PATH”] 設定環境變數?與 sys.path.append() 差別為何? Python: 如何使用 os.environ[“PATH”] 設定環境變數?與 sys.path.append() 差別為何?](https://i0.wp.com/savingking.com.tw/wp-content/uploads/2024/09/20240905135312_0_890fa1.png?quality=90&zoom=2&ssl=1&resize=350%2C233)





![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://i1.wp.com/savingking.com.tw/wp-content/uploads/2025/07/20250716084059_0_c5b368.png?quality=90&zoom=2&ssl=1&resize=350%2C233)



近期留言