0

i try to format the string to be:

${name123}

without string quotes between curly brackets. what i try to do :

dbname ="name123"
 db_name = f'\${ {dbname} }'
 print(db_name)

but the result is :

\${'name123'}

also i try with format :

dbname ="name123"
 db_name = f'\${ {0} }'.format(dbname)
 print(db_name)

but the result is :

\$name123

2 Answers 2

1

Try:

dbname = "name123"
db_name = "${{{}}}".format(dbname)
print(db_name)

Prints:

${name123}
Sign up to request clarification or add additional context in comments.

Comments

0

Try:

a = 'name123'
b = ('${' + a + '}')
print(b)

Prints:

${name123}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.