我正在try 查看在从python中执行grep之后,myfile是否不返回任何内容,如下所示:
command="cat my_file.txt | grep 'string_to_find'"
if os.system(command) == '':
print('nothing found')
我正在try 查看在从python中执行grep之后,myfile是否不返回任何内容,如下所示:
command="cat my_file.txt | grep 'string_to_find'"
if os.system(command) == '':
print('nothing found')
将 comments 转换为答案:
command="cat my_file.txt | grep 'string_to_find'"
if os.popen(command).read() == '':
print('nothing found')