【发布时间】:2021-05-31 18:16:20
【问题描述】:
我有一个多行文本,类似这样 -
a = """
Hi this is a sample line
Another line
Final line of the example.
"""
我有一个文本值 -
b = '00000000' # to insert in between
我需要将字符串 b 插入到字符串 a 的特定位置,例如 (2,1)(即第 2 行,字符 1),因为这就是我获得模式结果的方式来自某个模块的匹配(以 line_number、char_number 的形式)。
预期输出 -
a = """
Hi this is a sample line
A00000000nother line # <-- Entered string in line 2, after char 1 i.e. (2,1)
Final line of the example.
"""
非常感谢!
【问题讨论】:
-
请从intro tour 重复on topic 和how to ask。 “告诉我如何解决这个编码问题”不是堆栈溢出问题。我们希望您做出诚实的尝试,然后然后就您的算法或技术提出一个具体的问题。 Stack Overflow 并不打算取代现有的文档和教程。这是您重复有关字符串处理的教程的地方;这不是堆栈溢出问题。
标签: python python-3.x string full-text-search