python读取txt文件中的字符串,并将其中的数字输出

python读取txt文件中的字符串,找出字符串中的数字,并输出为字符串
file = open('route')
content = file.read()
s = [i for i in content if str.isdigit(i)]
s2 = ''.join(s)
print(s2)

 

猜你喜欢

转载自blog.csdn.net/u011622208/article/details/79427523
今日推荐