码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2014-10-20 09:53:45      阅读:221      评论:0      收藏:0      [点我收藏+]

标签:blog   http   io   os   ar   for   sp   div   on   

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

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 虎口里拔牙 括号中取东西

标签:blog   http   io   os   ar   for   sp   div   on   

原文地址:http://www.cnblogs.com/hope100/p/4036469.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!