demo
from os import system
system("cat hello.txt")
'''
hello
I am a demo file!
'''
一次性读取多个文件
from os import system
system("cat hello.txt world.txt")
'''
hello
I am a demo file!
hello
I am a demo file the second!
'''
要查看带行号的文件内容:
from os import system
system("cat -n hello.txt")
'''
1 hello
2 I am a demo file!
'''
要创建一个新的文件
from os import system
system("cat > hello1.txt")
#将在当前目录下的Python API中创建新文件
该文件将被创建,并要求用户在打开的终端中输入内容。要关闭输入,按CTRL+D
将多个文件合并为一个
from os import system
system("cat hello.txt world.txt > hello2.txt")
system("cat hello2.txt")
'''
hello
I am a demo file!
hello
I am a demo file the second!
'''