python给出一个字符串,将其中的字符“E”与空格替换后输出
时间: 2023-05-16 18:05:03 浏览: 71
可以使用字符串的 replace() 方法来实现:
```python
s = "Hello World! This is a test string with E in it."
s = s.replace("E", " ")
print(s)
```
输出结果为:
```
Hllo World! This is a tst string with in it.
```
相关问题
python实现给定一个字符串,将其中的字符E用空格替换输出
可以使用字符串的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.
```
python编写程序,给出一个字符串,将其中的字符“E”用空格替换后输出
可以使用字符串的 replace() 方法将字符 E 替换成空格,具体代码如下:
```python
s = "Hello, everyone! Enjoy Python programming!"
result = s.replace("E", " ")
print(result)
```
输出:
```
Hllo, vryon! njoy Python programming!
```