📜  python 从字符串中删除 \n - Python 代码示例

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

代码示例2
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