关于python中的字符串格式,';[%s]';意思是

关于python中的字符串格式,';[%s]';意思是,python,string,python-3.x,Python,String,Python 3.x,我看到一行代码: re.compile('[%s]' % re.escape(string.punctuation)) 但是我不知道[%s] 谁能帮我一下吗 谢谢大家! 这是一种字符串格式语法(它借用了C语言) 例如: name = input("What is your name? ") print("Hello %s, nice to meet you!" % name) 这就是程序的样子: What is your name? Johnny Hello Johnny, nice to

我看到一行代码:

re.compile('[%s]' % re.escape(string.punctuation))
但是我不知道
[%s]

谁能帮我一下吗


谢谢大家!

这是一种字符串格式语法(它借用了C语言)

例如:

name = input("What is your name? ")
print("Hello %s, nice to meet you!" % name)
这就是程序的样子:

What is your name? Johnny
Hello Johnny, nice to meet you!
你也可以用字符串排版来做这件事

name = input("What is your name? ")
print("Hello + name + ", nice to meet you!")
…但是,格式化通常更容易。 您还可以将其用于多个字符串

输出:

What is your name? Johnny
How old are you? 37
Are you a male or a female? male
Is this correct?
Your name is Johnny, you are 37 years old, and you are male.

现在,请在再问问题之前,看看它们是否存在

这是以前讨论过的问题。试着看一看,看看你是否能找到你要找的东西。可能的复制品意味着这是一个非常好的主意。
What is your name? Johnny
How old are you? 37
Are you a male or a female? male
Is this correct?
Your name is Johnny, you are 37 years old, and you are male.