×

Loading...

在看俄罗斯同事写的一段python 小程序


:


文字版在下面:

这个function 的定义:

def fun_run_OS_command(in_command, in_fl_to_run = True, in_fl_print_output = True, in_fl_remove_output_spaces = True, fl_print_command = True):
if in_fl_to_run:
if fl_print_command:
print_message("Running", in_command)
(loc_sub_output2, loc_sub_err) = subprocess.Popen(in_command, stdout=subprocess.PIPE, shell=True).communicate()
loc_sub_output = str(loc_sub_output2, 'utf-8')
if in_fl_remove_output_spaces:
loc_str_return = '\n'.join([tmp_line.strip() for tmp_line in loc_sub_output.strip().split("\n")])
if in_fl_print_output:
print(loc_str_return)
else:
if in_fl_print_output:
print(loc_sub_output)
print_sep('-')
return loc_str_return
else:
print_message("Debug mode, skip running", in_command)
return ''

调用这个function:

lc_comm = f"/usr/bin/ls -lrt {os.path.join(lc_log_dir, lc_log_mask)} | /usr/bin/tail -1"
lc_last_log_file_info = ss.fun_run_OS_command(lc_comm, in_fl_to_run = True, in_fl_print_output = False, in_fl_remove_output_spaces = True, fl_print_command = True)

这个f" 中的f 是干啥用的?


Sign in and Reply Report

Replies, comments and Discussions: