Questions about % of STATIC_URL="https://%s/%s/"%(AWS_S3_CUSTOM_DOMAIN, AWS_LOCATION)

Asked 2 months ago, Updated 2 months ago, 3 views

During the Amazon S3 implementation, the following code was found everywhere:

STATIC_URL="https://%s/%s/"%(AWS_S3_CUSTOM_DOMAIN,AWS_LOCATION)

Does this mean that each one should be substituted for %?
Or can I just paste it?

django amazon-s3

2022-09-30 13:44

2 Answers

S3 is one of Python's string expansion notation, regardless.

https://docs.python.org/ja/3.7/library/stdtypes.html#printf-style-string-formatting

If format %values (where format is a string), the %translation specification in format is replaced by zero or more elements in values.

How to embed variables in a string with Python
This blog might be easier to understand


2022-09-30 13:44

I think the following writing method is easier.

STATIC_URL=f "https://{AWS_S3_CUSTOM_DOMAIN}/{AWS_LOCATION}/"


2022-09-30 13:44

If you have any answers or tips


© 2022 OneMinuteCode. All rights reserved.