AI题库 · Python编程六级题库
题目分享 #6077
运行下面代码的正确结果是?
filename = "example.txt"
line_count = 0
with open(filename, "r") as file:
for line in file:
line_count += 1
print(f"The file 'example' has {line_count} lines.") 其中example.txt文件内容如下: My Favorite AnimalOnce upon a time, I had a pet dog named Max. Max was the most obedient dog I knew. We played fetch in the park, went on long walks in the woods, and even took naps together on lazy afternoons.
A
4
B
3
C
2
D
1
AI题库 · 编程考级与信奥赛真题库
查看答案 →
复制链接后可在微信、QQ、小红书等平台粘贴分享;答案与解析在题目页。