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


Python String.split方法代码示例

本文整理汇总了Python中java.lang.String.split方法的典型用法代码示例。如果您正苦于以下问题:Python String.split方法的具体用法?Python String.split怎么用?Python String.split使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.lang.String的用法示例。


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

示例1: decodeMessage

# 需要导入模块: from java.lang import String [as 别名]
# 或者: from java.lang.String import split [as 别名]
 def decodeMessage(wrapper, message):
     result = ""
     decoded = Base64.decodeBase64(message)
     try:
         Z = String(decoded, "UTF-8")
         result = Z.split(wrapper)[1]
     except Exception as ex:
         # Error decoding a Tango message.
         pass
     return result
开发者ID:sleuthkit,项目名称:autopsy,代码行数:12,代码来源:tangomessage.py

示例2: parseCommandLine

# 需要导入模块: from java.lang import String [as 别名]
# 或者: from java.lang.String import split [as 别名]
def parseCommandLine(argv):
    fullArgPairPattern = Pattern.compile("--\\w+=\\S*")
    justArgNamePattern = Pattern.compile("--\\w+")
    cmdParamProps = {}
    if (len(argv) > 0):
        for param in argv:
            cmdParam = String(param)
            fullMatcher = fullArgPairPattern.matcher(cmdParam)
            if (fullMatcher.matches()):
                (paramName, paramValue) = cmdParam.split("=")
                cmdParamProps[paramName] = paramValue
            else:
                nameMatcher = justArgNamePattern.matcher(cmdParam)
                if (nameMatcher.matches()):
                    cmdParamProps[param] = None
                else:
                    print("This " + param + " is not a Command Line parameter")
    return cmdParamProps
开发者ID:icecube00,项目名称:scripts-was-automation,代码行数:20,代码来源:get_log4j_conf_dir.py

示例3: splitIntoWords

# 需要导入模块: from java.lang import String [as 别名]
# 或者: from java.lang.String import split [as 别名]
def splitIntoWords(str):
    """Returns a list of non-word-character-separated words in str."""
    nonempty = lambda s: len(s) > 0
    return filter(nonempty, list(String.split(str, "\\W+")))
开发者ID:mit6005,项目名称:F14-EX24-words,代码行数:6,代码来源:Words2.py

示例4: splitIntoWords

# 需要导入模块: from java.lang import String [as 别名]
# 或者: from java.lang.String import split [as 别名]
def splitIntoWords(s):
    nonempty = lambda s: len(s) > 0
    return filter(nonempty, list(String.split(s, "\\W+")))
开发者ID:hxu,项目名称:learning,代码行数:5,代码来源:Words2.py

示例5: __reportSearch

# 需要导入模块: from java.lang import String [as 别名]
# 或者: from java.lang.String import split [as 别名]
    def __reportSearch(self):
        self.reportId = self.request.getParameter("id")
        self.format = self.request.getParameter("format")
        self.report = self.reportManager.getReports().get(self.reportId)
        self.reportQuery = self.report.getQueryAsString()
        self.log.debug("Report query: " + self.reportQuery)
        
        #Get a total number of records
        try:
            out = ByteArrayOutputStream() 
            recnumreq = SearchRequest(self.reportQuery)
            recnumreq.setParam("rows", "0")
            self.indexer.search(recnumreq, out)
            recnumres = SolrResult(ByteArrayInputStream(out.toByteArray()))
            self.__rowsFoundSolr = "%s" % recnumres.getNumFound()
        except:
            self.errorMsg = "Query failure. The issue has been logged (%s - %s)." % (sys.exc_info()[0], sys.exc_info()[1])
            self.log.error("Reporting threw an exception (report was %s): %s - %s" % (self.report.getLabel(), sys.exc_info()[0], sys.exc_info()[1]))
            return
        
        #Setup the main query
        req = SearchRequest(self.reportQuery)
        req.setParam("fq", 'item_type:"object"')
        req.setParam("fq", 'workflow_id:"dataset"')
        req.setParam("rows", self.__rowsFoundSolr)
        try:                
            #Now do the master search
            out = ByteArrayOutputStream()
            self.indexer.search(req, out)
            self.__reportResult = SolrResult(ByteArrayInputStream(out.toByteArray()))
            self.__checkResults()
        except:
            self.errorMsg = "Query failure. The issue has been logged (%s - %s)." % (sys.exc_info()[0], sys.exc_info()[1])
            self.log.error("Reporting threw an exception (report was %s): %s - %s" % (self.report.getLabel(), sys.exc_info()[0], sys.exc_info()[1]))
            return
        
        #At this point the display template has enough to go with.
        #We just need to handle the CSV now
        if (self.format == "csv"):
            #Setup the main query - we need to requery to make sure we return 
            #only the required fields. We'll use the specific IDs that met the
            #__checkResults check
            req = SearchRequest(self.reportQuery)
            req.setParam("fq", 'item_type:"object"')
            req.setParam("fq", 'workflow_id:"dataset"')
            req.setParam("rows", self.__rowsFoundSolr)
            req.setParam("csv.mv.separator",";")
            
            #we need to get a list of the matching IDs from Solr
            #this doesn't work for long queries so it's abandoned
            #but left here commented to make sure we don't try it again
            #idQry = ""
            #for item in self.getProcessedResultsList():
            #    idQry += item.get("id") + " OR "
            #req.setParam("fq", 'id:(%s)' % idQry[:len(idQry)-4])
            
            #Create a list of IDs for reference when preparing the CSV
            idQryList = []
            for item in self.getProcessedResultsList():
                idQryList.append(item.get("id"))
            
            #Setup SOLR query with the required fields
            self.fields = self.systemConfig.getArray("redbox-reports","csv-output-fields")
            #We must have an ID field and it must be the first field
            fieldString = "id,"
            if self.fields is not None:                
                for field in self.fields:
                    fieldString = fieldString+ field.get("field-name")+","
                fieldString = fieldString[:-1]
                
            req.setParam("fl",fieldString)
            
            out = ByteArrayOutputStream()
            try:
                self.indexer.search(req, out, self.format)
            except:
                #We can't get the result back from SOLR so fail back to the template display
                self.errorMsg = "Query failure. Failed to load the data - this issue has been logged (%s - %s)." % (sys.exc_info()[0], sys.exc_info()[1])
                self.log.error("Reporting threw an exception (report was %s); Error: %s - %s" % (self.report.getLabel(), sys.exc_info()[0], sys.exc_info()[1]))
                return
            try:
                csvResponseString = String(out.toByteArray(),"utf-8")
                csvResponseLines = csvResponseString.split("\n")
            except:
                #We can't get the result back from SOLR so fail back to the template display
                self.errorMsg = "Query failure. Failed to prepare the CSV - this issue has been logged (%s - %s)." % (sys.exc_info()[0], sys.exc_info()[1])
                self.log.error("Reporting threw an exception (report was %s); Error: %s - %s" % (self.report.getLabel(), sys.exc_info()[0], sys.exc_info()[1]))
                return
            
            fileName = self.urlEncode(self.report.getLabel())
            self.log.debug("Generating CSV report with file name: " + fileName)
            self.response.setHeader("Content-Disposition", "attachment; filename=%s.csv" % fileName)
            
            sw = StringWriter()
            parser = CSVParser()
            writer = CSVWriter(sw)
            count = 0
            
            prevLine = ""
            badRowFlag = False
#.........这里部分代码省略.........
开发者ID:greg-pendlebury,项目名称:redbox,代码行数:103,代码来源:reportResult.py


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