dailinqing 2020-05-03
code
def is_number(s):
try:
float(s)
return True
except ValueError:
pass
return False
# 测试字符串和数字
print(is_number(‘foo‘)) # False
print(is_number(‘1‘)) # True
print(is_number(‘1.3‘)) # True
print(is_number(‘-1.37‘)) # True
print(is_number(‘1e3‘)) # True >>> a = " a b c ". # replace主要用于字符串的替换replace. # join为字符字符串合成传入一个字符串列表,split用于字符串分割可以按规则进行分割。>>> c =