creating a new text file using heredoc

Viewed 3373

In my shell script, I use heredoc block to create a file on the fly. What is the python equivalent?

cat > myserver.pem << "heredoc"
-----BEGIN RSA PRIVATE KEY-----
MIIEpQIBAAKCAQEAnTsiYssvsuM1DRjyhqD8+ZB8ESqUFHgzeBYONp3yqjK8ICw/LRrxjXGXidAW
aPBXfktv3zN/kFsLMEFJKrJs/TLCfXG1CwFHMZzJRLM4aE6E0j6j+KF96cY5rfAo82rvP5kQdTIm
-----END RSA PRIVATE KEY-----
heredoc

I am looking for a simple solution. I really like the above shell script code. Can I use it "as is" in python?

1 Answers
Related