一、旧式的字符串格式化
% 操作符
参考以下示例:
>>> name = "Eric"
>>> "Hello, %s." % name
'Hello, Eric.'
当有多个变量需要插入到字符串中时:
>>> name = "Eric"
>>> age = 74
>>> "Hello, %s. You are %s." % (name, age)
'Hello, Eric. You are 74.'
当
一、旧式的字符串格式化
% 操作符
参考以下示例:
>>> name = Eric
>>> Hello, %s. % name
'Hello, Eric.'
当有多个变量需要插入到字符串中时:
>>> name = Eric
>>> age = 74
>>> Hello, %s. You are %s. % (name, age)
'Hello, Eric. You are 74.'
当需要替换的变