python - % 对 Python 中的字符串有什么作用?

标签 python string documentation operators

我找不到运算符 % 的文档,因为它用于 Python 中的字符串。这个运算符与左侧的字符串一起使用时会做什么?

最佳答案

是字符串格式化操作符。阅读 string formatting in Python .

format % values

创建一个字符串,其中 format 指定格式,values 是要填写的值。

关于python - % 对 Python 中的字符串有什么作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1238306/

相关文章:

Python 如何扩展 `str` 并重载其构造函数?

java - 将 JSON 转换为排序 JSON,其中包含嵌套节点中的 JSONArray

ios - 为什么 Appledoc 对输入参数类的引用没有突出显示?

php - 将 phpdoc 转换为 Dash 可用的 docset

documentation - ExtJs 日历文档或一些示例代码?

python - 正则表达式在Python中抛出异常

python - 有没有一种方法可以将函数应用于具有相同外部索引的多索引数据帧切片,而无需迭代每个切片?

c - strncpy 和 strcat 用法

python - 在 matplotlib 中移动和调整图例框的大小

python - 在 python 中比较并从列表中提取字符串