• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python string.atof函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中string.atof函数的典型用法代码示例。如果您正苦于以下问题:Python atof函数的具体用法?Python atof怎么用?Python atof使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了atof函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: HexamerFeatures

def HexamerFeatures(seq,hash_matrix):
    if len(seq) < 6:
		return(0,0)
    frame_sequence = list(seq)
    frame_seq_length = len(frame_sequence)
    CDS_array = []
    for o in range(0,3):
        frame_TempStr = ''
        frame_TempStr = InitCodonSeq(o,frame_seq_length-2,3,frame_sequence)
        frame_array = frame_TempStr.split(' ') ## codon array
        frame_array.pop()
        other_num = 0
        frame_array_Len = len(frame_array) - 1
        for j in range(frame_array_Len):
            temp2 = frame_array[j]+frame_array[j+1]
            temple4 = re.compile('[atcg]{6}')
            if temple4.match(temp2):
                other_num = string.atof(other_num) + string.atof(hash_matrix[temp2])
        frame_array_Len = frame_array_Len + 2
        other_num = other_num / frame_array_Len
        CDS_array.append(other_num)      
    Mscore = max(CDS_array)
    score_distance = 0
    for m in range(0,3): #problem location
        score_distance += Mscore - CDS_array[m]
    score_distance = score_distance/float(2)   

    return(Mscore,score_distance)
开发者ID:xiaofengsong,项目名称:lncScore,代码行数:28,代码来源:lncScore.py


示例2: dealline

def dealline(rdlin,sepin):
    rdlsplit=rdlin.split(sepin)
    x0=string.atof(rdlsplit[1])
    y0=string.atof(rdlsplit[2])
    x1=string.atof(rdlsplit[3])
    y1=string.atof(rdlsplit[4])
    return x0,y0,x1,y1
开发者ID:weepingdog,项目名称:ArcpyScriptToolkits,代码行数:7,代码来源:caculfour.py


示例3: _read_data

    def _read_data(self, fp, pos):
        fp.seek(pos)
        size = fp.readline().split()
        self.nrow = atoi(size[0])
        self.ncol = atoi(size[1])
        self.shape = (self.nrow, self.ncol)
        self.nnz = atoi(size[2])
        self.irow = np.empty(self.nnz, dtype=np.int)
        self.jcol = np.empty(self.nnz, dtype=np.int)

        if self.dtype is not None:
            self.values = np.empty(self.nnz, dtype=self.dtype)

        # Read in data
        k = 0
        for line in fp.readlines():
            line = line.split()
            self.irow[k] = atoi(line[0]) - 1
            self.jcol[k] = atoi(line[1]) - 1
            if self.dtype == np.int:
                self.values[k] = atoi(line[2])
            elif self.dtype == np.float:
                self.values[k] = atof(line[2])
            elif self.dtype == np.complex:
                self.values[k] = complex(atof(line[2]), atof(line[3]))
            k += 1

        return k
开发者ID:PythonOptimizers,项目名称:HSL.py,代码行数:28,代码来源:mtx.py


示例4: monitor

def monitor(url, price_accpet):
    idx = 0
    timenow = time.strftime("%Y-%m-%d %X", time.localtime())
    while True:
    #for idx in range(COUNTER):
        try:
            page = urllib2.urlopen(url, timeout=1000)
            page = unicode(page.read(), "gb2312", "ignore").encode("gb2312", "ignore")
            soup = BeautifulSoup(page, fromEncoding="gb18030")
            global subject_header
            subject_header = soup.html.head.title.string
            print subject_header
            subject_header = ''.join(subject_header.encode('utf-8').split('【')[:-1])
            print subject_header
            skuid = url.split('/')[-1].split('.')[0]
            f = urllib2.urlopen('http://p.3.cn/prices/get?skuid=J_'+skuid, timeout=5)
        except Exception, ex:
            print ex, 'timenow:%s,couldnot open this %s' % (timenow, url)
            continue
        price = json.loads(f.read())
        f.close()
        #print price_promotion
        price_promotion = price[0]['p']
        print price_promotion, price_accpet
        if string.atof(price_promotion) < string.atof(price_accpet):
            message = ''.join(['价格降低到 ', (price_promotion.encode('utf-8'))])
            subject_header = ''.join([subject_header, message])
            print subject_header, '----', message
            send_mail(message)
            break
        time.sleep(60)
开发者ID:fuhao715,项目名称:python,代码行数:31,代码来源:urlHtmlPara.py


示例5: signOR

def signOR(ntot,ns,curs):
        ORv={}
        snpor = curs.fetchall()
        desc = curs.description
        ntot += 1
        founds=0;
        for OR in snpor: ### check all CI
                for (name, value) in zip(desc, OR) :
                        ORv[name[0]] = value   
                pval = ORv['Pvalue'] 
                ci = ORv['CI']
               # print pval
                #print ci
                if founds == 0:
                        if  ci is not None:
                               # print 'y',ci
                                c0=string.atof(ci.split("-", 1)[0])
                                c1=string.atof(ci.split("-", 1)[1])
                                if(c1 >1 and  c0> 1)  or (c0 <1 and c1 < 1): 
                                        founds +=1
                        elif pval is not None and  pval <=0.05:
                               #print 'z', pval
                                founds +=1
                       # elif  pval is None and ci is not None:
                      
                else:
                        break  
        ns += founds
        return (ntot,ns)
开发者ID:celinesf,项目名称:personal,代码行数:29,代码来源:score_algophen_01-09-12.py


示例6: rescale_canvas_cb

  def rescale_canvas_cb(self, value):

    value = string.atof(value)
    cur_value = math.log10(self.current_zoom_factor)
    if abs(cur_value - value) > .5 * string.atof(self.zscale['resolution']):
      factor = math.pow(10.0, value) / self.current_zoom_factor
      self.zoom_by_factor(factor, 0)
开发者ID:CONNJUR,项目名称:SparkyExtensions,代码行数:7,代码来源:tkutil.py


示例7: gui_updateMarkers

 def gui_updateMarkers(self):
     M=self.GM.Marker
     M.equalize()
     n=M.number
     for i in range(n):
         gm=self.guiMarkers[i]
         s=self.guiVar[i][1].get()
         if s==0:
             M.status[i]='off'
         else:
             M.status[i]='on'
         a=gm[3].getcurselection()
         M.size[i]=string.atoi(gm[5].get(0.0,Tkinter.END))
         M.symbol[i]=gm[3].getcurselection()
         M.color[i]=gm[4].get()
         M.id[i]=gm[6].get(0.0,Tkinter.END)[:-1]
         M.id_size[i]=string.atoi(gm[7].get(0.0,Tkinter.END))
         x=string.atof(gm[8].get(0.0,Tkinter.END))
         y=string.atof(gm[9].get(0.0,Tkinter.END))
         M.xoffset[i]=x
         M.yoffset[i]=y
         M.id_color[i]=gm[10].get()
         M.id_font[i]=string.atoi(gm[11].getcurselection())
         M.line[i]=string.lower(gm[12].getcurselection())
         if M.line[i]=='none' : M.line[i]=None
         M.line_type[i]=gm[13].getcurselection()
         M.line_size[i]=string.atof(gm[14].get(0.0,Tkinter.END))
         M.line_color[i]=gm[15].get()
开发者ID:AZed,项目名称:uvcdat,代码行数:28,代码来源:gui_taylor.py


示例8: parseGSA

    def parseGSA(self, words):
        if len(words[1]):
            (self.mode, self.LATLON) = self.update(self.mode, string.atoi(words[1]), self.LATLON)
            self.fix = ["none", "2d", "3d"][string.atoi(words[1]) - 1]
        else:
            self.fix = "none"

        usedSatellites = [int(i) for i in words[2:13] if i != ""]

        for prn, sat in self.sats.iteritems():
            if prn in usedSatellites:
                sat.used = True
                sat.gsaLast = self.gsaLast
            elif self.gsaLast - sat.gsaLast > 2:
                sat.used = False

        self.gsaLast += 1

        if words[14] != "":
            self.pdop = string.atof(words[14])
        if words[15] != "":
            self.hdop = string.atof(words[15])
        if words[16] != "":
            self.vdop = string.atof(words[16])
            if self.vdop == 0:
                self.vdop = None
开发者ID:yellowpoplar,项目名称:qgismapper,代码行数:26,代码来源:NMEA.py


示例9: down

def down(each, j, data):
	url = 'http://www.worldweather.cn/zh/json/'+str(each)+'_zh.xml'
	html = urllib2.urlopen(url).read()
	con = json.loads(html)['city']
	name = con['cityName']
	memName = con['member']['memName']
	data.write(j, 0, name)
	data.write(j, 1, memName)
	data.write(j, 2, each)
	month_list = con['climate']['climateMonth']
	list_len = len(month_list)
	for i in range(list_len):
		#print i['month'],i['minTemp'],i['maxTemp'],i['rainfall'],i['raindays']
		minTemp = month_list[i]['minTemp']
		maxTemp = month_list[i]['maxTemp']
		rainfall = month_list[i]['rainfall']
		raindays = month_list[i]['raindays']
		print month_list[i]['month'], minTemp, maxTemp, rainfall, raindays
		if not func(minTemp):
			minTemp = 0
		if not func(maxTemp):
			maxTemp = 0
		if not func(rainfall):
			rainfall = 0
		if not func(raindays):
			raindays = 0
		data.write(j, 4*i+3, string.atof(minTemp))
		data.write(j, 4*i+4, string.atof(maxTemp))
		data.write(j, 4*i+5, string.atof(rainfall))
		data.write(j, 4*i+6, string.atof(raindays))
开发者ID:shiyazhou121,项目名称:python,代码行数:30,代码来源:save_excel.py


示例10: fromXYZrecord

 def fromXYZrecord(cls,aline):
     AtomStr  = string.split(aline)[0:4]
     name = AtomStr[0]
     x = string.atof(AtomStr[1])
     y = string.atof(AtomStr[2])
     z = string.atof(AtomStr[3])
     return cls(name,[x,y,z])
开发者ID:jeffhammond,项目名称:nwchem,代码行数:7,代码来源:myatom.py


示例11: do_lat_lon

 def do_lat_lon(self, words):
     if len(words[0]) == 0 or len(words[1]) == 0:  # empty strings?
         return
     if words[0][-1] == "N":
         words[0] = words[0][:-1]
         words[1] = "N"
     if words[0][-1] == "S":
         words[0] = words[0][:-1]
         words[1] = "S"
     if words[2][-1] == "E":
         words[2] = words[2][:-1]
         words[3] = "E"
     if words[2][-1] == "W":
         words[2] = words[2][:-1]
         words[3] = "W"
     if len(words[0]):
         lat = string.atof(words[0])
         frac, intpart = math.modf(lat / 100.0)
         lat = intpart + frac * 100.0 / 60.0
         if words[1] == "S":
             lat = -lat
         (self.lat, self.LATLON) = self.update(self.lat, lat, self.LATLON)
     if len(words[2]):
         lon = string.atof(words[2])
         frac, intpart = math.modf(lon / 100.0)
         lon = intpart + frac * 100.0 / 60.0
         if words[3] == "W":
             lon = -lon
         (self.lon, self.LATLON) = self.update(self.lon, lon, self.LATLON)
开发者ID:yellowpoplar,项目名称:qgismapper,代码行数:29,代码来源:NMEA.py


示例12: TF_rotate

  def TF_rotate( self, c = [] ):
    s = c[0]
    n = string.atoi( c[1] )

    # direction
    u = numpy.array( [ 0.0, 0.0, 0.0 ] )
    u[0] = string.atof( c[2] )
    u[1] = string.atof( c[3] )
    u[2] = string.atof( c[4] )
    # angle
    t = string.atof( c[5] )

    self.cart()
    atom = self.get( n )
    if atom.symbol != s:
      raise Warning( "Symbol mismatch" )
    # end if
    origo = atom.position
    print " TF/rotate origo"
    atom.info()
    print " TF/rotate",u,t

    R = ROT(u,t)

    # copy atoms
    for atom in self.atoms:
      dv = atom.position - origo
      dv = numpy.dot(R,dv)
      atom.position = dv + origo
    # end for
    self.direct()

    return self
开发者ID:hornos,项目名称:pyf3,代码行数:33,代码来源:Geometry.py


示例13: AUTOatof

def AUTOatof(input_string):
    #Sometimes AUTO messes up the output.  I.e. it gives an
    #invalid floating point number of the form x.xxxxxxxE
    #instead of x.xxxxxxxE+xx.  Here we assume the exponent
    #is 0 and make it into a real real number :-)
    try:
        value=string.atof(input_string)
    except (ValueError):
        try:
            if input_string[-1] == "E":
                #  This is the case where you have 0.0000000E
                value=string.atof(strip(input_string)[0:-1])
            elif input_string[-4] == "-":
                #  This is the case where you have x.xxxxxxxxx-yyy
                value=0.0
            else:
                print "Encountered value I don't understand"
                print input_string
                print "Setting to 0"
                value=0.0
        except:
            print "Encountered value which raises an exception while processing!!!"
            print input_string
            print "Setting to 0"
            value=0.0
            
            
    return value
开发者ID:pratikmallya,项目名称:AUTO,代码行数:28,代码来源:parseB.py


示例14: storeTimedCurrentCostDatav2

    def storeTimedCurrentCostDatav2(self, reftimestamp, ccdb, hist):
        global trc
        trc.FunctionEntry("storeTimedCurrentCostDatav2")

        # months
        for i in range(1, 10):
            key = "m0" + str(i)
            ccdb.StoreMonthData(self.GetOldMonth(reftimestamp, i), atoi(hist['mths'][key]))
        for i in range(10, 13):
            key = "m" + str(i)
            ccdb.StoreMonthData(self.GetOldMonth(reftimestamp, i), atoi(hist['mths'][key]))

        # days
        for i in range(1, 10):
            key = "d0" + str(i)
            ccdb.StoreDayData(self.GetOldDay(reftimestamp, i),  atoi(hist['days'][key]))
        for i in range(10, 32):
            key = "d" + str(i)
            ccdb.StoreDayData(self.GetOldDay(reftimestamp, i),  atoi(hist['days'][key]))

        # hours
        for i in range(2, 9, 2):
            key = "h0" + str(i)
            ccdb.StoreHourData(self.GetOldHour(reftimestamp, i - 2),  atof(hist['hrs'][key]))
        for i in range(10, 27, 2):
            key = "h" + str(i)
            ccdb.StoreHourData(self.GetOldHour(reftimestamp, i - 2),  atof(hist['hrs'][key]))

        trc.FunctionExit("storeTimedCurrentCostDatav2")
开发者ID:jdarknet,项目名称:gconsumos,代码行数:29,代码来源:currentcostdataconvert.py


示例15: usageAct

 def usageAct(self):
     name=self.__name
     pid=self.__pid
     useAge="top -bn 1 -p %s |grep %s | awk '{print $9}'"%(pid,pid)
     vcpustime="virsh vcpuinfo %s |grep 'CPU time'|awk '{split($3,b,\"s\");print b[1]}'"%(name)
     usedtime="virsh cpu-stats %s --total|awk 'NR>2{print $2}'|awk 'BEGIN{sum=0}{sum+=$1}END{print sum}'"%(name)
     
     files=os.popen(useAge)
     useAgeTmp=files.readline()
     
     if useAgeTmp:
         useAge=string.atof(useAgeTmp)
     else:
         useAge=0
         
     files=os.popen(usedtime)
     usedTimeTmp=files.readline()
     if usedTimeTmp:
         usedTime=string.atof(usedTimeTmp)
     else:
         usedTime=0
     files=os.popen(vcpustime)
     sts=""
     while True:
         strs=files.readline()
         if strs:
             sts+=strs[:-1]+","
         else:
             break
     self.__dataSlot["cpu"]["core_time"]=sts
     self.__dataSlot["cpu"]["usedTime"]="%.3f"%(usedTime)
     self.__dataSlot["cpu"]["useAge"]=useAge
开发者ID:gaoyangxiaozhu,项目名称:learn-docker,代码行数:32,代码来源:cpu.py


示例16: single

def single():
  infile = open('Doc/SMutList','r')
  outfile = open('result/SingleSub.txt','w')
  header  = "\t".join(['Substitution-WTaa','Substitution-Pos','Substitution-Mutaa','InputCount','SelectionCount(SumOfTriplicates)'])
  outfile.write(header+"\n")
  Shash = {}
  for line in infile.xreadlines():
    if 'Mut' in line: continue
    line   = line.rstrip().rsplit("\t")
    mut    = line[0]
    DNA    = line[1]
    sel1   = int(line[3])
    sel2   = int(line[4])
    sel3   = int(line[5])
    SEL    = line[6]
    wtaa   = mut[0]
    pos    = str(int(mut[1:-1])+1)
    mutaa  = mut[-1]
    out    = "\t".join([wtaa,pos,mutaa,DNA,SEL])
    outfile.write(out+"\n")
    DNAfreq  = atof(DNA)/atof(line[7])
    Selfreq  = atof(SEL)/atof(line[12])
    fit = Selfreq/DNAfreq
    Shash[wtaa+pos+mutaa] = fit
  infile.close()
  outfile.close()
  return Shash
开发者ID:dailei1987,项目名称:DoubleMutFit2DDG,代码行数:27,代码来源:FinalTableAO1.py


示例17: loadData

 def loadData(self, fName):
     # a CVRP has a demand for each node
     self.nodeAttributes += [ 'demand' ]
     self.globalAttributes += [ 'capacity', 'maximum duration' ]
     self.nodes = []
     self.attributes = {}
     # load a Christofides, Mingozzi and Toth instance
     cpt = 0
     for line in file.readlines(file(fName)):
         line = line.split()
         if len(line) > 3:
             self.attributes['directed'] = False
             self.attributes['capacity'] = string.atoi(line[1])
             self.attributes['maximum duration'] = string.atoi(line[2])
         elif len(line) >= 2:
             thisNode = {}
             thisNode['index'] = cpt
             thisNode['label'] = str(cpt)
             thisNode['is depot'] = True if cpt == 0 else False
             thisNode['demand'] = string.atoi(line[2])\
                 if len(line) > 2 else 0
             thisNode['x'] = string.atof(line[0])
             thisNode['y'] = string.atof(line[1])
             self.nodes.append(thisNode)
             cpt += 1
         else:
             continue
开发者ID:fa-bien,项目名称:proute,代码行数:27,代码来源:cvrp.py


示例18: __init__

    def __init__(self,iptFile,ctFile,truncTime):
        # Read epidemic and truncate to truncTime
        self.infectives = []
        self.labels = []
        epiFile = open(iptFile,'r')
        for line in epiFile:
            toks = line.split()
            label = atoi(toks[0])
            I = atof(toks[1])
            N = atof(toks[2])
            R = atof(toks[3])
            if N <= truncTime: # Take individuals who have been notified by truncTime
                if R > truncTime: # If R > truncTime, set R = truncTime
                    R = truncTime
                self.infectives.append(Infective(label,I,N,R))
                self.labels.append(label)
        epiFile.close()

                
        # Read in XML
        conFile = Uri.OsPathToUri(ctFile)
        xmlSrc = DefaultFactory.fromUri(conFile,stripElements=[(EMPTY_NAMESPACE,'*',1)])
        self.doc = NonvalidatingReader.parse(xmlSrc)

        # Remove from the contact DOM any contact info
        #   for individuals that are not present in labels
        self.labels = set(self.labels)
        for contact in self.doc.documentElement.xpath(u'tc:contact',explicitNss={u'tc':u'tracedcontacts'}):
            contactLabel = atoi(contact.getAttributeNS(None,u'id'))
            if contactLabel not in self.labels:
                self.doc.documentElement.removeChild(contact)
开发者ID:chrism0dwk,项目名称:AIContactTracing,代码行数:31,代码来源:truncateSim.py


示例19: __handle_value

 def __handle_value(self,value,iskey=False):
     tp=self.__value_type(value)
     if tp=="datetime":
         year,month,day=atoi(value[:4])-1850,atoi(value[5:7]),atoi(value[8:10])
         hour,minute,second=atoi(value[11:13]),atoi(value[14:16]),atoi(value[17:19])
         d=date(year=year,month=month,day=day).toordinal()
         t=(hour*60+minute)*60+second
         return "T"+struct.pack("H",d)+struct.pack("I",t)
     elif tp=="date":
         year,month,day=atoi(value[:4])-1850,atoi(value[5:7]),atoi(value[8:10])
         d=date(year=year,month=month,day=day).toordinal()
         return "D"+struct.pack("H",d)
     elif tp=="int":
         return "I"+struct.pack("I",atoi(value))
     elif tp=="float":
         return "F"+struct.pack("f",atof(value))
     elif tp=="@":
         pattern=re.compile("(\d+)@(\d+\.\d+)")
         match=pattern.match(value)
         volume,price=atoi(match.group(1)),atof(match.group(2))
         return "A"+struct.pack("I",volume)+"@"+struct.pack("f",price)
     else:
         if iskey:
             if not self.table_key.has_key(value):
                 self.table_key[value]=len(self.table_key)+1
             return "M"+struct.pack("B",self.table_key[value])[0]
         else:
             return "S"+str(value)
开发者ID:SnowWalkerJ,项目名称:HiggsCompress,代码行数:28,代码来源:__init__.py


示例20: read_positions

  def read_positions( self ):
    j = 1
    for s in self.species:
      for i in range( 0, self.species[s] ):
        if j > 1:
          self.getline()
        # end if
        # POSCAR or CHGCAR
        try:
          ( x, y, z, xm, ym, zm, no, symb ) = self.line()
        except:
          ( x, y, z, no, symb ) = self.line()
          xm = ym = zm = 'T'
        # end try
        x = string.atof( x )
        y = string.atof( y )
        z = string.atof( z )
        no = string.atoi( no )

        # without renumbering
        self.geom.add( AtomPos( symbol = symb, no = no, 
                                vec = [ x, y, z ], 
                                moveable = [ xm, ym, zm ] ), False )
        if self.debug:
          print " %05d Process:" % self.lc(), "%4d" % j, "%3d" % i, "%2s" % s, self.line()
        # end if
        j += 1
开发者ID:hornos,项目名称:pyf3,代码行数:27,代码来源:diff.py



注:本文中的string.atof函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python string.atoi函数代码示例发布时间:2022-05-27
下一篇:
Python models.User类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap