Python Remove Character at Specified Position from String

Document 对象参考手册Python3 Examples

Given a string, then remove the character at the specified position:

Example

test_str = "Example"
 
# Output the original string
print ("The original string is : " + test_str)
 
# Remove the third character n
new_str = ""
 
for i in range(0, len(test_str)):
    if i != 2:
        new_str = new_str + test_str[i]

print ("The string after removal is : " + new_str)

Executing the above code produces the following output:

原始字符串为 : Example
字符串移除后为 : Ruoob

Document 对象参考手册Python3 Examples

Other Extensions