How do I pass variables in the command to be executed by subprocess?

for example, I now have a variable date="2018", and I want to use subprocess to execute the following linux command, such as touch date.txt, that is touch 2018.txt. How can this be implemented?

Mar.28,2021

the simple way is to use subprocess's call, such as

.
subprocess.call(["touch", date + ".txt"])

if you have more requirements for child processes, such as non-blocking calls. You can use the relatively complex subprocess.Popen

Menu