如何使用 python 在终端中显示文本文件
How to display a text file in the terminal with python
我的文件夹中有 2 个文件:
text.txt
main.py
我想在 main.py
为 运行 时在终端中显示 text.txt
中写入的文本。
我该怎么做?
with open('text.txt', 'r') as f:
print(f.read())
我的文件夹中有 2 个文件:
text.txt
main.py
我想在 main.py
为 运行 时在终端中显示 text.txt
中写入的文本。
我该怎么做?
with open('text.txt', 'r') as f:
print(f.read())