当前位置: 首页>>代码示例>>Python>>正文


Python string.atoi函数代码示例

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


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

示例1: varParse

def varParse(entry):
    id=0
    title='None'
    units='None'
    datatype=slats.LatsFloat
    leveltype=''
    scale_fac=-999
    precision=-999
    comment1=''
    comment2=''
    nentry = len(entry)
    if nentry>1: id = string.atoi(entry[1])
    if nentry>2: title = string.strip(entry[2])
    if nentry>3: units = string.strip(entry[3])
    if nentry>4: 
	if string.lower(string.strip(entry[4]))=='float':
	    datatype = slats.LatsFloat
	else:
	    datatype = slats.LatsInt
    if nentry>5: leveltype = string.strip(entry[5])
    if nentry>6: scale_fac = string.atoi(entry[6])
    if nentry>7: precision = string.atoi(entry[7])
    if nentry>8: comment1 = string.strip(entry[8])
    if nentry>9: comment2 = string.strip(entry[9])
    return [id,title,units,datatype,leveltype,scale_fac,precision,comment1,comment2]
开发者ID:AZed,项目名称:uvcdat,代码行数:25,代码来源:latsParmTab.py

示例2: get_ms_space

def get_ms_space(ms_local):    
    try:
        # get disk space
        url = 'http://%s:%d/macross?cmd=querydisk' % (ms_local.controll_ip, ms_local.controll_port)
        print url
        req = urllib2.Request(url)
        response = urllib2.urlopen(req, timeout=10)
        output = response.read()
        print output
        #return=ok
        #result=12|22005|2290
        lines = output.split('\n')
        if(len(lines)>=2):
            line_1 = lines[0].strip()
            line_2 = lines[1].strip()
            if(line_1 == 'return=ok'):
                fields = line_2.split('=')
                field2 = fields[1]
                values = field2.split('|')
                ms_local.total_disk_space = string.atoi(values[1])
                ms_local.free_disk_space = string.atoi(values[2])
                ms_local.save()
                return True
    except:
        print '%s get disk space error' % (ms_local.controll_ip)        
    return False
开发者ID:goggle1,项目名称:MSMaster3,代码行数:26,代码来源:views.py

示例3: evaluateDiagnose

def evaluateDiagnose(diagnoseId):
    userId=session['uesrId']
    if userId is None:
        return json.dumps(rs.NO_LOGIN.__dict__,ensure_ascii=False)
    userId=string.atoi(userId)

    score=request.args.get('score')
    description=request.args.get('description')
    if score:
        score=string.atoi(score)
    else:
        return  json.dumps(rs.PARAM_ERROR.__dict__,ensure_ascii=False)

    diagnose=Diagnose.getDiagnoseById(diagnoseId)
    if diagnose is None:
        return  json.dumps(rs.NO_DATA.__dict__,ensure_ascii=False)
    if hasattr(diagnose,'patient') and diagnose.patient and diagnose.patient.userID and  diagnose.patient.userID==userId:
        diagnose.status=constant.DiagnoseStatus.Diagnosed
        diagnose.score=score
        Diagnose.save(diagnose)

        diagoseLog=DiagnoseLog(userId,diagnoseId,constant.DiagnoseLogAction.DiagnoseFinished)
        diagoseLog.description=description
        DiagnoseLog.save(db_session,diagoseLog)
        return  json.dumps(rs.SUCCESS.__dict__,ensure_ascii=False)
    else:
        return  json.dumps(rs.PERMISSION_DENY.__dict__,ensure_ascii=False)
开发者ID:LichuanLu,项目名称:blueberry,代码行数:27,代码来源:diagnose.py

示例4: CheckFillFile

def CheckFillFile(fillfile):
    myfile=open(fillfile,'r').readlines()
    valid=True
    for r in myfile[1:]:
        temp=string.split(r)
        if len(temp)<3:
            valid=False
            print "Bad line '%s' in fillfile '%s':  not enough arguments"%(r,fillfile)
            return valid
        try:
            fill=string.atoi(temp[0])
        except:
            print "Bad line '%s' in fillfile '%s':  can't read fill # as an integer"%(r,fillfile)
            valid=False
            return valid
        try:
            runs=string.strip(temp[2])
            runs=string.split(runs,",")
            for run in runs:
                try:
                    string.atoi(run)
                except:
                    valid=False
                    print "Bad line '%s' in fillfile '%s':  can't parse runs"%(r,fillfile)
                    return valid
        except:
            print "Bad line '%s' in fillfile '%s':  can't ID runs"%(r,fillfile)
            valid=False
            return valid
    print "<CheckFillFile>  fill file '%s' appears to be formatted correctly!"%fillfile
    return valid
开发者ID:rodenm,项目名称:StoppedHSCP,代码行数:31,代码来源:pyGetFillScheme.py

示例5: unescape

def unescape(input):
    result = input[:]

    aliases = {
        "quot": "\"",
        "amp":  "&",
        "gt":   ">",
        "lt":   "<"
    }

    pattern = r"&((?:#\d+)|(?:(?:\w|\d)+));"
    while True:
        match = re.search(pattern, result)
        if match is None:
            break

        value = match.group(1)
        if aliases.has_key(value):
            result = result[:match.start()] + aliases[value] + result[match.end():]
        elif value[0] == "#":
            if value[1].lower() == "x":
                value = unichr(string.atoi(value[2:], 16))
            else:
                value = unichr(string.atoi(value[1:]))
            result = result[:match.start()] + value + result[match.end():]

    return result
开发者ID:alphashooter,项目名称:caketest,代码行数:27,代码来源:html.py

示例6: decodeDP_POI

def decodeDP_POI(C):
        I = -1;
        H = 0;
        B = "";
        J = len(C);
        G = C[J - 1];
        C = C[0: J - 1];
        J -= 1
        for E in range(0, J):
            D = string.atoi(C[E], settings['cha']) - settings['add'];
            if D >= settings['add']:
                D = D - settings['plus']
            B += intToStr (D, settings['cha'])
            if D > H:
                I = E;
                H = D
        A = string.atoi(B[0:I], settings['digi']);
        F = string.atoi(B[I + 1:], settings['digi']);
        L = float(A + F - string.atoi(G, 36)) / 2;
        K = float(F - L) / 100000;
        L = float(L) / 100000;
        return {
            'lat': K,
            'lng': L
        }
开发者ID:hkg36,项目名称:gaetests,代码行数:25,代码来源:fetchurl.py

示例7: ChkCommAddr

    def ChkCommAddr(self, event):
        sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)        
        EDIdInput = self.EDId.GetValue()
        #EDMacInput = self.EDMac.GetValue()
        EDNetIdInput = self.EDNetId.GetValue()
        
        #EDMacInputList = EDMacInput.split(' ')
        #Mac1 = hex(int(EDMacInputList[0], 16))
        #Mac2 = hex(int(EDMacInputList[1], 16))
        #Mac3 = hex(int(EDMacInputList[2], 16))
        #Mac4 = hex(int(EDMacInputList[3], 16))
        #Mac5 = hex(int(EDMacInputList[4], 16))
        #print Mac1,Mac2,Mac3,Mac4,Mac5

        self.LogInfo.AppendText('校验通讯地址' + "\r\n")
        #self.LogInfo.AppendText('EDMacInput ' + EDMacInput + "\r\n")
        self.LogInfo.AppendText('EDIdInput ' + EDIdInput + "\r\n")
        self.LogInfo.AppendText('EDNetIdInput ' + EDNetIdInput + "\r\n")
        
        ChkAddrMsg = struct.pack('!3l', 1155, string.atoi(EDNetIdInput), string.atoi(EDIdInput))
        #self.LogInfo.AppendText(ChkAddrMsg)
        self.LogInfo.AppendText(repr(ChkAddrMsg) + "\r\n")
        self.LogInfo.AppendText("\r\n")

        #sock.sendto(ChkAddrMsg, ('10.30.141.220', 5555))
        sock.sendto(ChkAddrMsg, ('127.0.0.1', 5555))
        #szBuf = sock.recvfrom(1024)
        #self.LogInfo.AppendText("recv " + szBuf + "\r\n")
        sock.close();
        #self.LogInfo.AppendText("end of connect" + "\r\n")

        self.BtnChkCommAddr.SetLabel("校验通讯地址")
开发者ID:BloodShow,项目名称:test,代码行数:32,代码来源:grid.py

示例8: __normalize

 def __normalize(self, event=None):
     ew = event.widget
     contents = ew.get()
     icursor = ew.index(INSERT)
     if contents == '':
         contents = '0'
     if contents[0] in 'xX' and self.__hexp.get():
         contents = '0' + contents
     # figure out what the contents value is in the current base
     try:
         if self.__hexp.get():
             v = string.atoi(contents, 16)
         else:
             v = string.atoi(contents)
     except ValueError:
         v = None
     # if value is not legal, delete the last character inserted and ring
     # the bell
     if v is None or v < 0 or v > 255:
         i = ew.index(INSERT)
         if event.char:
             contents = contents[:i-1] + contents[i:]
             icursor = icursor-1
         ew.bell()
     elif self.__hexp.get():
         contents = hex(v)
     else:
         contents = int(v)
     ew.delete(0, END)
     ew.insert(0, contents)
     ew.icursor(icursor)
开发者ID:Claruarius,项目名称:stblinux-2.6.37,代码行数:31,代码来源:TypeinViewer.py

示例9: readRain

def readRain(fpath,iskp):
    #iskp  the total line skipped of the file
    # fpath   the full path of the file
    # usage: onedim=readAscii(fpaht,iskp)
    onedim=[]
    ystr=[]
    mstr=[]
    dstr=[]
    linesplit=[]
    datestr=[]
    f=open(fpath)
    ff=f.readlines()[iskp:]  ## first line in obs file is legend 
    for line in ff:
        line=string.lstrip(line)
        linesplit1=line[:-1].split(' ')
        datestr.append(linesplit1[0])
        linesplit.append(linesplit1[1:])
    for lnstrs in linesplit:
        #print lnstrs          
        for strs in lnstrs:
            if strs!='':
                #print strs
                onedim.append(string.atof(strs))
    for lnstrs in datestr:           
        ystr.append(string.atoi(lnstrs[0:4]))
        mstr.append(string.atoi(lnstrs[4:6]))
        dstr.append(string.atoi(lnstrs[6:8]))
    del linesplit1
    f.close()
    return ystr,mstr,dstr,onedim
开发者ID:cheenor,项目名称:PhD02,代码行数:30,代码来源:circullation_patterns_select.py

示例10: elong_request_parser

def elong_request_parser(content):
    
    result = -1

    try:
        infos = content.split('|')
        flight_info = infos[0].strip()
        time_info = infos[1].strip()
        ticketsource = infos[2].strip()

        flight_no = flight_info.split('-')[0]
        dept_id,dest_id = flight_info.split('-')[1],flight_info.split('-')[2]

        #date:20140510,time:09:10
        dept_day,dept_hour = time_info.split('_')[0],time_info.split('_')[1]

        dept_date = dept_day[0:4] + '-' + dept_day[4:6] + '-' + dept_day[6:]#2014-05-10

        dept_time = dept_date + 'T' + dept_hour + ':00'

        dept_id = cities_dict[dept_id]
        dest_id = cities_dict[dest_id]
        location = dept_id +  '-' + dest_id

        origday = datetime.datetime(string.atoi(dept_date[0:4]),string.atoi(dept_date[5:7]),string.atoi(dept_date[8:]))
        urlday = (origday - datetime.datetime.today()).days
        #dept_date = orig_date
        #logger.info('contents: %s %s %s %s '%(location,flight_no,dept_date,str(urlday)))
    except Exception,e:
        logger.error(str(e))
        logger.error('Content Error: Wrong content format with %s'%content)
        return result
开发者ID:dangpu,项目名称:momoko,代码行数:32,代码来源:elongRequestParser.py

示例11: getImageData

    def getImageData(self,preserveAspectRatio=False):
        "Gets data, height, width - whatever type of image"
        image = self.image

        if type(image) == StringType:
            self.filename = image
            if os.path.splitext(image)[1] in ['.jpg', '.JPG', '.jpeg', '.JPEG']:
                (imagedata, imgwidth, imgheight) = self.jpg_imagedata()
            else:
                if not self.imageCaching:
                    imagedata = pdfutils.cacheImageFile(image,returnInMemory=1)
                else:
                    imagedata = self.cache_imagedata()
                words = string.split(imagedata[1])
                imgwidth = string.atoi(words[1])
                imgheight = string.atoi(words[3])
        else:
            import sys
            if sys.platform[0:4] == 'java':
                #jython, PIL not available
                (imagedata, imgwidth, imgheight) = self.JAVA_imagedata()
            else:
                (imagedata, imgwidth, imgheight) = self.PIL_imagedata()
        self.imageData = imagedata
        self.imgwidth = imgwidth
        self.imgheight = imgheight
        self.width = self.width or imgwidth
        self.height = self.height or imgheight
开发者ID:alexissmirnov,项目名称:donomo,代码行数:28,代码来源:pdfimages.py

示例12: extractQueryFromRequest

def extractQueryFromRequest(rec, request):
    post_field = dataplus.dictGetVal(request.REQUEST, 'post_field', '')
    query = models.RecruiterRecentSearchQuery(recruiter=rec.account)
    if post_field != '':
        pickled_query = dataplus.dictGetVal(request.REQUEST,post_field)
        query_dic = cPickle.loads(pickled_query)
        
        if query_dic['industry_category'] != '':
            query.industry_category = models.IndustryCategory.objects.get(name=query_dic['industry_category'])
        query.designation = query_dic['designation']
        query.mandatory_skills = query_dic['mandatory_skills']
        query.desired_skills = query_dic['desired_skills']
        query.location = query_dic['location']
        query.min_exp_years = query_dic['min_exp_years']
        query.max_exp_years = query_dic['max_exp_years']
        query.qualifications = query_dic['educational_qualifications']
    else:
        if dataplus.dictGetVal(request.REQUEST, 'industry_category', '') != '':
            query.industry_category = models.IndustryCategory.objects.get(name=request.REQUEST['industry_category'])
        query.designation = dataplus.dictGetVal(request.REQUEST, 'designation', escapeHtml=True)
        query.mandatory_skills = dataplus.dictGetVal(request.REQUEST, 'mandatory_skills', escapeHtml=True)
        query.desired_skills = dataplus.dictGetVal(request.REQUEST, 'desired_skills', escapeHtml=True)
        query.location = dataplus.dictGetVal(request.REQUEST, 'location', escapeHtml=True)
        exp = string.split(request.REQUEST['experience'],'-')
        query.min_exp_years = string.atoi(exp[0])
        query.max_exp_years = string.atoi(exp[1])
        query.educational_qualifications = dataplus.dictGetVal(request.REQUEST, 'educational_qualifications', escapeHtml=True)
    return query
开发者ID:TayebJa3ba,项目名称:socialray,代码行数:28,代码来源:recruiters_searchresults.py

示例13: getLOSS

def getLOSS(st_ip,ed_ip):
    part1 = "'%(rexmt-data-bytes)d / %(transport-layer-byte)d'"
    part2 = '%s:*-%s:*'%(st_ip,ed_ip)
    part3 = "'"+part2+"'"
    filename = 'loss_'+st_ip+'_'+ed_ip+'.txt'
    cmd = "captcp statistic --format %s --filter %s trace2.txt >./%s"%(part1,part3,filename)
    os.system(cmd)
    floss = open(filename)
    tran = 0.0;
    retran = 0.0;
    try:
        lines = floss.readlines()
        for line in lines:
            mid = line.find('/')
            ed = line.find('\n')
            retran = retran + (float)(string.atoi(line[0:mid-1]))
            tran = tran + (float)(string.atoi(line[mid+2:ed]))
        if(tran == 0.0):
            loss = 0
        else:
            loss = retran / tran
        loss = float('%0.4f'%loss)
        print 'data loss from %s to %s:'%(st_ip,ed_ip),loss
    finally:
        floss.close()
        
    os.system('sudo rm -rf %s'%filename)
    return loss
开发者ID:liaohui0114,项目名称:Project_NetworkMeasurement,代码行数:28,代码来源:Passive.py

示例14: vertDimParse

def vertDimParse(entry):
    description = 'None'
    units = 'None'
    verticality = slats.SingleLevel
    positive = slats.UpDirection
    grib_id = 0
    grib_p1 = 0
    grib_p2 = 0
    grib_p3 = 0
    nentry = len(entry)
    if nentry>1: description = string.strip(entry[1])
    if nentry>2: units = string.strip(entry[2])
    if nentry>3:
	if string.lower(string.strip(entry[3]))=='single':
	    verticality = slats.SingleLevel
	else:
	    verticality = slats.MultiLevel
    if nentry>4:
	if string.lower(string.strip(entry[4]))=='up':
	    positive = slats.UpDirection
	else:
	    positive = slats.DownDirection
    if nentry>5: grib_id = string.atoi(entry[5])
    if nentry>6: grib_p1 = string.atoi(entry[6])
    if nentry>7: grib_p2 = string.atoi(entry[7])
    if nentry>8: grib_p3 = string.atoi(entry[8])
    return [description, units, verticality, positive, grib_id, grib_p1, grib_p2, grib_p3]
开发者ID:AZed,项目名称:uvcdat,代码行数:27,代码来源:latsParmTab.py

示例15: lanceScriptSVDetect

def lanceScriptSVDetect():
    #liStrains = ['55-86_1','62-196','62-1041','67-588','CBS2861','CBS4104','CBS4568','CBS5828','CBS6545','CBS6547','CBS6626','CBS10367','CBS10368','dd281a','DBVPG3108','DBVPG4002','68917-2','CBS10369','CBS6546','DBVPG3452','NRBC101999','NRBC10572','NRBC10955','NRBC1811','NRBC1892']
    #liStrains = ['55-86_1','62-196','62-1041','67-588','CBS2861']
    #liStrains = ['CBS4104','CBS4568','CBS5828','CBS6545','CBS6547']
    #liStrains = ['CBS6626','CBS10367','CBS10368','dd281a','DBVPG3108']
    #liStrains = ['DBVPG4002','68917-2','CBS10369','CBS6546','DBVPG3452']
    liStrains = ['NRBC101999', 'NRBC10572', 'NRBC10955', 'NRBC1811', 'NRBC1892']

    workdir = "/Volumes/BioSan/Users/dpflieger/SVDetect"
    #workdir = "/Volumes/BioSan/Users/jhou/Documents/Incompatibility/StructuralVariants/SVDetect"
    mapLen = "/Volumes/BioSan/Users/dpflieger/Data/saklChromMap.len"
    #mapLen = "%s/saceChromMap.len" % workdir
    for strain in liStrains:
        repOut = "%s/%s" % (workdir, strain)
        confFile = "%s/%s.sv.conf" % (repOut, strain)
        #os.system("touch %s" %confFile)
        # au BGI, long de 100
        readLen = 100
        #bamFile = "%s/aln_%s_PE-rel.sorted.ab.bam" % (repOut,strain)
        #bamFile = "/Volumes/BioSan/Users/dpflieger/BWA/%s/alnFin-%sPE-rel.sorted.inRef.ab.bam" % (strain,strain)
        bamFile = "/Volumes/BioSan/Users/dpflieger/SVDetect/%s/alnFin-%sPE-rel.sorted.inRef.ab.bam" % (strain, strain)
        preSVfile = "/Volumes/BioSan/Users/dpflieger/SVDetect/%s/preProcess_%s.log" % (strain, strain)
        lPreProc = getMuSigmaFromSVdetectPreProcess(preSVfile)
        mu = string.atoi(lPreProc[0])
        sigma = string.atoi(lPreProc[1])
        createSVConfFile(confFile, strain, bamFile, readLen, mapLen, mu, sigma)

        cmd = "/Volumes/BioSan/opt/SVDetect_r0.7m/bin/SVDetect linking filtering -conf %s" % (confFile)
        os.system(cmd)
        cmd2 = "/Volumes/BioSan/opt/SVDetect_r0.7m/bin/SVDetect links2SV -conf %s" % (confFile)
        os.system(cmd2)
开发者ID:bioinfocoderz,项目名称:Scripts,代码行数:31,代码来源:SVDetect.py


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