python实现给定一个字符串,将其中的字符E用空格替换输出
时间: 2023-05-29 16:03:06 浏览: 444
可以使用字符串的replace()方法来实现:
```
s = "Hello World! This is a test string."
new_s = s.replace("E", " ")
print(new_s)
```
输出:
```
Hllo World! This is a t st string.
```
相关问题
编写程序,给出一个字符串,将其中的字符"E"用空格替换后输出
假设给定的字符串为s,可以使用Python中的字符串替换函数replace()来实现字符替换功能:
```python
s = "Hello, World! This is an example."
s = s.replace("E", " ")
print(s)
```
输出结果为:
```
Hllo, World! This is an xampl .
```
给出一一个字符串,将其中的字符“E”用空格替换后输出。
假设给定的字符串为str,可以用以下代码实现:
```python
str = str.replace("E", " ")
print(str)
```
这里使用了字符串的replace()方法,将所有的字符"E"替换为一个空格。最后输出替换后的字符串。