📌  相关文章
📜  从字符串中删除 n 个字符 python 代码示例

📅  最后修改于: 2022-03-11 14:46:14.758000             🧑  作者: Mango

代码示例4
example_string = "Hello there"

def remove_chars(n, string):
    list_of_chars_in_string = [char for char in string] 
    
    for num in range(n):
        list_of_chars_in_string.pop() # Removes last n characters in string
    
    new_string = ''.join(list_of_chars_in_string)
    return new_string