import re fp = open('c:/1.txt', 'r') s = fp.readline() print(s) aList = re.findall('([-+]?\d+(\.\d*)?|\.\d+)([eE][-+]?\d+)?',s) #使用正规表达式搜索字符串 print(aList) for ss in aList: print(ss[0]+ss[2]) aNum = float((ss[0]+ss[2])) print(aNum) fp.close()
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn