python课程:移除字符串中的指定位置字符

课程任务

给定一个字符串,然后移除指定位置的字符。

代码

test_str = "xinggyu"
 
# 输出原始字符串
print ("原始字符串为 : " + test_str)
# 移除第三个字符 n
new_str = ""
 
for i in range(0, len(test_str)):
    if i != 4:
        new_str = new_str + test_str[i]

print ("字符串移除后为 : " + new_str)

发表评论

您的邮箱地址不会被公开。 必填项已用 * 标注

购物车
  • Your cart is empty.
Scroll to Top