首页 > 代码库 > python 虎口里拔牙 括号中取东西

python 虎口里拔牙 括号中取东西

怎么获取 [ ]中的字符串或者数字

http://stackoverflow.com/questions/4894069/python-regex-help-return-text-between-parenthesis

例程:

[[ 1.1916991]]
[[ 0.87677399]]
[[ 0.69110944]]
[[ 0.65589256]]

 

def readTxtToList():	fp_read = open("readTest.txt", "r")	readNum = []		for line in fp_read:		readNum = line[line.find("[")+1:line.find("]")]		print readNum		readNum = readNum[readNum.find("[")+1:]		print readNum			fp_read.close()	readTxtToList()

  

python 虎口里拔牙 括号中取东西