python - 当第三个 str.replace() 参数为负时会发生什么?
问题描述
请解释这里发生了什么?
print("banana".replace('a','1',-3))
输出是:
b1n1n1
解决方案
根据票 5416:
负值在某种程度上被用作标记值来表示全部替换。
推荐阅读
- c - “使用未声明的标识符‘高度’”的问题 mario.c
- javascript - Reactjs重定向网址更改但组件未加载
- c++ - 为已经转换的 QGraphicsItem 设置转换原点
- python-3.x - 使用 kafka 运行 Faust 会导致 ConsumerStoppedError 崩溃
- python - Python 评论:为什么代码 1 产生的结果与代码 2 不同?
- azure-devops - Azure Pipeline - 为什么需要参数值
- datetime - 可以在没有日期信息的情况下解析时间字符串吗?
- spring - spring boot 2.1.3 以后抛出循环引用
- flutter - 我有一个关于在 initstate 中使用异步函数的问题
- redis - 如何将 aof 文件重新加载到 Redis