如何将带有换行符的长字符串追加到列表中并保留 换行
test=[]
test.append({"parameter": ''' hello there
my name is Hamed
how are you
''' })
print(test)
当我尝试这个时,我会得到
[{'parameter': ' hello there\nmy name is Hamed\nhow are you\n'}]
而不是在那里打招呼。我的名字是Hamed 我想要
[{'parameter': "hello there
my name is hamed
how are you?" }]
basicaly我试图保持格式相同而不是使用\ n。这很重要,因为我试图通过cloudformation传递证书,这种格式一直搞乱我的证书,因为它用\ n打印证书,我得到的证书质量很差,例如这是我得到的证书。
[{'parameter': ' -----BEGIN CERTIFICATE-----\nMIIEwTCCA6mgAwIBAgIJAP4MuzUmKZLZMA0GCSqGSIb3DQEBCwUAMIGbMQswCQYD\nVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4g\nVmlldzESMBAGA1UEChMJRE5BIE5leHVzMQ0wCwYDVQQLEwRQcm9kMRgwFgYDVQQD\nEw9oYW1lZCBoYWRkYWRpYW4xIjAgBgkqhkiG9w0BCQEWE2hhbWVkaEBkbmFuZXh1\ncy5jb20wHhcNMTcwMTEzMDMxNzA2WhcNMTgwMTEzMDMxNzA2WjCBmzELMAkGA1UE\nBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDU1vdW50YWluIFZp\nZXcxEjAQBgNVBAoTCUROQSBOZXh1czENMAsGA1UECxMEUHJvZDEYMBYGA1UEAxMP\naGFtZWQgaGFkZGFkaWFuMSIwIAYJKoZIhvcNAQkBFhNoYW1lZGhAZG5hbmV4dXMu\nY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArU6WTiEtUGPt/p+d\nqgJMyTKwXyeiiFLbI4w7Q9Ve3TXaYhqYCX+5ET7O54E4iBOJM0MKxJYXS6QO4hhC\nvuKaCrehs8GaXssE+F1yOP4nadAukw4OnFzsXOEfCHToSAxxH+FcFuXerSUj8lm/\nASY36IFseySvzyPJ+B9sRdt+8leb7ZctfMGK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