Apr-12-2022, 11:40 AM
(Apr-12-2022, 11:32 AM)paulo79 Wrote:(Apr-11-2022, 11:53 PM)snippsat Wrote: String formatting and now usef-string
new in Python 3.6 ➡
>>> VARIABLE = 12 >>> s = f"cat /tmp/logall | sort -u | grep -v {VARIABLE}" >>> s 'cat /tmp/logall | sort -u | grep -v 12'
Is there a way to in python 2.7? I cannot use 3 yet.
I found it:
>>> VARIABLE=12 >>> v_num_final_distinct_grid_disks_per_cell_and_dg = subprocess.check_output("cat /tmp/logall | sort -u | grep -v {}".format(VARIABLE), shell=True); >>> >>> print(v_num_final_distinct_grid_disks_per_cell_and_dg) 10 >>> VARIABLE=10 >>> v_num_final_distinct_grid_disks_per_cell_and_dg = subprocess.check_output("cat /tmp/logall | sort -u | grep -v {}".format(VARIABLE), shell=True); >>> print(v_num_final_distinct_grid_disks_per_cell_and_dg) 12 >>>