Python 2.7通过str.replace从字符串中删除空格不起作用

时间:2017-06-01 07:01:06

标签: python-2.7 whitespace

我想从字符串中删除空格,但str.replace无法正常工作。请帮忙

1
s = "asd dsa asd "
string.replace(s, 'est', '')

NameError: name 'string' is not defined


2
s = "asd asd dsa "
str.replace(s, " ", "")
print s
Output: asd asd dsa 

3
s = "asd asd dsa "
s.replace(" ", "")
print s
Output: asd asd dsa 

0 个答案:

没有答案