在我的代码中,我需要使用$
删除def
符号,并需要将它们转换为numbers
以进行计算。
def remove_dollar(s):
"""Removes dollar signs and spaces from s.
Returns it as a float.
"""
# YOUR CODE HERE
s = sales(s)
s.remove('$')
return ''.join(s)
remove_dollar(sales['LastSpend'])
答案 0 :(得分:0)
您可以尝试:
用空字符串替换$
。
s = s.replace('$',"")
完整功能:
def remove_dollar(s):
"""Removes dollar signs and spaces from s.
Returns it as a float.
"""
# YOUR CODE HERE
s = sales(s)
s = s.replace('$',"")
return s
remove_dollar(sales['LastSpend'])