Код: Выделить всё
f_name = "John"
l_name = "Smith"
sample = f`{f_name}'s last name is {l_name}.`
print(sample)
< /code>
Я знаю, что могу использовать (php): < /p>
$num = 5;
$location = 'tree';
$format = 'There are %d monkeys in the %s';
echo sprintf($format, $num, $location);
Код: Выделить всё
$db_type = $settings['db_type']; # mysql
$db_host = $settings['db_host']; # localhost
$db_name = $settings['db_name']; # sample
var $format = "%s:host=%s; dbname=%s";
# Not sure what to do after that, but I can use string concatenation:
var $format = $db_type + ":host=" + $db_host + "; dbname=" + $db_name;
var $connection = new PDO($format, $db_user, $db_password);
Подробнее здесь: https://stackoverflow.com/questions/548 ... str-format
Мобильная версия