I want to save the aws command in a variable.
#!/usr/bin/python3
import subprocess
aa = (subprocess.check_output(['aws ce get-cost-and-usage --time-period Start=2020-08-01,End=2020-08-31 --granularity=DAILY --metrics BlendedCost |grep Amount | awk '{ gsub('\"',''); print $2 }' | sed 's/.$//''], shell=True)).decode('ascii').strip()
print(aa)
File "test.py", line 5
aa = (subprocess.check_output(['aws ce get-cost-and-usage --time-period Start=2020-08-01,End=2020-08-31 --granularity=DAILY --metrics BlendedCost |grep Amount | awk '{ gsub('\"',''); print $2 }' | sed 's/.$//''], shell=True)).decode('ascii').strip()
^
SyntaxError: invalid syntax
What is the problem?
)at the end of that line, next, you need to escape those'i.e.\'