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


Python string.lower方法代码示例

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


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

示例1: getsourcefile

# 需要导入模块: import string [as 别名]
# 或者: from string import lower [as 别名]
def getsourcefile(object):
    """Return the filename that can be used to locate an object's source.
    Return None if no way can be identified to get the source.
    """
    filename = getfile(object)
    if string.lower(filename[-4:]) in ('.pyc', '.pyo'):
        filename = filename[:-4] + '.py'
    for suffix, mode, kind in imp.get_suffixes():
        if 'b' in mode and string.lower(filename[-len(suffix):]) == suffix:
            # Looks like a binary file.  We want to only return a text file.
            return None
    if os.path.exists(filename):
        return filename
    # only return a non-existent filename if the module has a PEP 302 loader
    if hasattr(getmodule(object, filename), '__loader__'):
        return filename
    # or it is in the linecache
    if filename in linecache.cache:
        return filename 
开发者ID:glmcdona,项目名称:meddle,代码行数:21,代码来源:inspect.py

示例2: BuildModule

# 需要导入模块: import string [as 别名]
# 或者: from string import lower [as 别名]
def BuildModule(module, built_nodes, rootNode, create_node_fn, create_node_args ):
    if module:
        keep = module.__name__
        keep = keep and (built_nodes.get(module) is None)
        if keep and hasattr(module, '__file__'):
            keep = string.lower(os.path.splitext(module.__file__)[1]) not in [".pyd", ".dll"]
#               keep = keep and module.__name__=='__main__'
    if module and keep:
#        print "keeping", module.__name__
        node = ModuleTreeNode(module)
        built_nodes[module] = node
        realNode = create_node_fn(*(node,)+create_node_args)
        node.realNode = realNode

        # Split into parent nodes.
        parts = string.split(module.__name__, '.')
        if parts[-1][:8]=='__init__': parts = parts[:-1]
        parent = string.join(parts[:-1], '.')
        parentNode = rootNode
        if parent:
            parentModule = sys.modules[parent]
            BuildModule(parentModule, built_nodes, rootNode, create_node_fn, create_node_args)
            if parentModule in built_nodes:
                parentNode = built_nodes[parentModule].realNode
        node.Attach(parentNode) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:27,代码来源:debugger.py

示例3: test

# 需要导入模块: import string [as 别名]
# 或者: from string import lower [as 别名]
def test(serverName):
    if string.lower(serverName)==string.lower(win32api.GetComputerName()):
        print "You must specify a remote server name, not the local machine!"
        return

    # Hack to overcome a DCOM limitation.  As the Python.Interpreter object
    # is probably installed locally as an InProc object, DCOM seems to ignore
    # all settings, and use the local object.
    clsctx = pythoncom.CLSCTX_SERVER & ~pythoncom.CLSCTX_INPROC_SERVER
    ob = win32com.client.DispatchEx("Python.Interpreter", serverName, clsctx=clsctx)
    ob.Exec("import win32api")
    actualName = ob.Eval("win32api.GetComputerName()")
    if string.lower(serverName) != string.lower(actualName):
        print "Error: The object created on server '%s' reported its name as '%s'" % (serverName, actualName)
    else:
        print "Object created and tested OK on server '%s'" % serverName 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:18,代码来源:testDCOM.py

示例4: diskcheck_convert

# 需要导入模块: import string [as 别名]
# 或者: from string import lower [as 别名]
def diskcheck_convert(value):
    if value is None:
        return []
    if not SCons.Util.is_List(value):
        value = string.split(value, ',')
    result = []
    for v in map(string.lower, value):
        if v == 'all':
            result = diskcheck_all
        elif v == 'none':
            result = []
        elif v in diskcheck_all:
            result.append(v)
        else:
            raise ValueError(v)
    return result 
开发者ID:coin3d,项目名称:pivy,代码行数:18,代码来源:SConsOptions.py

示例5: printSources

# 需要导入模块: import string [as 别名]
# 或者: from string import lower [as 别名]
def printSources(self, hierarchy, commonprefix):
        sorteditems = hierarchy.items()
        # TODO(1.5):
        #sorteditems.sort(lambda a, b: cmp(a[0].lower(), b[0].lower()))
        sorteditems.sort(lambda a, b: cmp(string.lower(a[0]), string.lower(b[0])))

        # First folders, then files
        for key, value in sorteditems:
            if SCons.Util.is_Dict(value):
                self.file.write('\t\t\t<Filter\n'
                                '\t\t\t\tName="%s"\n'
                                '\t\t\t\tFilter="">\n' % (key))
                self.printSources(value, commonprefix)
                self.file.write('\t\t\t</Filter>\n')

        for key, value in sorteditems:
            if SCons.Util.is_String(value):
                file = value
                if commonprefix:
                    file = os.path.join(commonprefix, value)
                file = os.path.normpath(file)
                self.file.write('\t\t\t<File\n'
                                '\t\t\t\tRelativePath="%s">\n'
                                '\t\t\t</File>\n' % (file)) 
开发者ID:coin3d,项目名称:pivy,代码行数:26,代码来源:msvs.py

示例6: read_sequence_from_fasta

# 需要导入模块: import string [as 别名]
# 或者: from string import lower [as 别名]
def read_sequence_from_fasta(fin, bpstart, bpend, line_length=50.0):
    bpstart=bpstart-1
    
    fin.seek(0)
    fin.readline()  #read the first line; the pointer is at the second line

    nbp = bpend - bpstart
    offset = int( bpstart + math.floor(bpstart/line_length)) #assuming each line contains 50 characters; add 1 offset per line
    
    if offset > 0:
        fin.seek(int(offset),1)

    seq = fin.read(nbp+int(math.floor(nbp/line_length))+1)
    seq = seq.replace('\n','')

    if len(seq) < nbp: 
        print 'Coordinate out of range:',bpstart,bpend
    
    return seq[0:nbp].lower() 
开发者ID:lucapinello,项目名称:Haystack,代码行数:21,代码来源:bioutilities.py

示例7: estimate_background

# 需要导入模块: import string [as 别名]
# 或者: from string import lower [as 别名]
def estimate_background(self):
        counting={'a':.0,'c':.0,'g':.0,'t':.0}
        all=0.0
        
        for chr_id in self.chr.keys():
            if self.verbose:
                print 'Counting on:',chr_id
            
            self.chr[chr_id].seek(0)
            self.chr[chr_id].readline()
            
            for line in self.chr[chr_id]:
                for nt in counting.keys():
                    count_nt=line.lower().count(nt)
                    counting[nt]+=count_nt
                    all+=count_nt
        
        if self.verbose:
            print counting
        
        for nt in counting.keys():
            counting[nt]/=all
            
        return counting 
开发者ID:lucapinello,项目名称:Haystack,代码行数:26,代码来源:bioutilities.py

示例8: base36

# 需要导入模块: import string [as 别名]
# 或者: from string import lower [as 别名]
def base36(s):
    n = 0
    for c in string.lower(s):
        if c.isdigit():
            n = n * 36 + ord(c) - ord('0')
            continue
        if c.isalpha():
            n = n * 36 + ord(c) - ord('a') + 10
            continue
        n = n * 36 + 35  #treat everything else as a 'z'
    return n 
开发者ID:sdn-ixp,项目名称:iSDX,代码行数:13,代码来源:tnode.py

示例9: equalsIgnoreCase

# 需要导入模块: import string [as 别名]
# 或者: from string import lower [as 别名]
def equalsIgnoreCase(a, b):
    """Return true iff a and b have the same lowercase representation.
    
    >>> equalsIgnoreCase('dog', 'Dog')
    1
    >>> equalsIgnoreCase('dOg', 'DOG')
    1
    """
    # test a == b first as an optimization where they're equal
    return a == b or string.lower(a) == string.lower(b)


#
# Sequence Utility Functions
# 
开发者ID:rafasashi,项目名称:razzy-spinner,代码行数:17,代码来源:wntools.py

示例10: getWord

# 需要导入模块: import string [as 别名]
# 或者: from string import lower [as 别名]
def getWord(self, form, line=None):
	key = string.replace(string.lower(form), ' ', '_')
	pos = self.pos
	def loader(key=key, line=line, indexFile=self.indexFile):
	    line = line or indexFile.get(key)
	    return line and Word(line)
	word = _entityCache.get((pos, key), loader)
	if word:
	    return word
	else:
	    raise KeyError, "%s is not in the %s database" % (`form`, `pos`) 
开发者ID:rafasashi,项目名称:razzy-spinner,代码行数:13,代码来源:wordnet.py

示例11: _equalsIgnoreCase

# 需要导入模块: import string [as 别名]
# 或者: from string import lower [as 别名]
def _equalsIgnoreCase(a, b):
    """Return true iff a and b have the same lowercase representation.
    
    >>> _equalsIgnoreCase('dog', 'Dog')
    1
    >>> _equalsIgnoreCase('dOg', 'DOG')
    1
    """
    return a == b or string.lower(a) == string.lower(b)

#
# File utilities
# 
开发者ID:rafasashi,项目名称:razzy-spinner,代码行数:15,代码来源:wordnet.py

示例12: adjust_case

# 需要导入模块: import string [as 别名]
# 或者: from string import lower [as 别名]
def adjust_case(self, word, stem):
        lower = string.lower(word)

        ret = ""

        for x in xrange(len(stem)):
            if lower[x] == stem[x]:
                ret = ret + word[x]
            else:
                ret = ret + stem[x]

        return ret

    ## --NLTK--
    ## Don't use this procedure; we want to work with individual
    ## tokens, instead.  (commented out the following procedure)
    #def stem(self, text):
    #    parts = re.split("(\W+)", text)
    #    numWords = (len(parts) + 1)/2
    #    
    #    ret = ""
    #    for i in xrange(numWords):
    #        word = parts[2 * i]
    #        separator = ""
    #        if ((2 * i) + 1) < len(parts):
    #            separator = parts[(2 * i) + 1]
    #
    #        stem = self.stem_word(string.lower(word), 0, len(word) - 1)
    #        ret = ret + self.adjust_case(word, stem)
    #        ret = ret + separator
    #    return ret

    ## --NLTK--
    ## Define a stem() method that implements the StemmerI interface. 
开发者ID:rafasashi,项目名称:razzy-spinner,代码行数:36,代码来源:porter.py

示例13: parse_timedelta

# 需要导入模块: import string [as 别名]
# 或者: from string import lower [as 别名]
def parse_timedelta(val):
    """
    returns a ``timedelta`` object, or None
    """
    if not val:
        return None
    val = string.lower(val)
    if "." in val:
        val = float(val)
        return timedelta(hours=int(val), minutes=60*(val % 1.0))
    fHour = ("h" in val or ":" in val)
    fMin  = ("m" in val or ":" in val)
    fFraction = "." in val
    for noise in "minu:teshour()":
        val = string.replace(val, noise, ' ')
    val = string.strip(val)
    val = string.split(val)
    hr = 0.0
    mi = 0
    val.reverse()
    if fHour:
        hr = int(val.pop())
    if fMin:
        mi = int(val.pop())
    if len(val) > 0 and not hr:
        hr = int(val.pop())
    return timedelta(hours=hr, minutes=mi) 
开发者ID:linuxscout,项目名称:mishkal,代码行数:29,代码来源:datetimeutil.py

示例14: parse_time

# 需要导入模块: import string [as 别名]
# 或者: from string import lower [as 别名]
def parse_time(val):
    if not val:
        return None
    hr = mi = 0
    val = string.lower(val)
    amflag = (-1 != string.find(val, 'a'))  # set if AM is found
    pmflag = (-1 != string.find(val, 'p'))  # set if PM is found
    for noise in ":amp.":
        val = string.replace(val, noise, ' ')
    val = string.split(val)
    if len(val) > 1:
        hr = int(val[0])
        mi = int(val[1])
    else:
        val = val[0]
        if len(val) < 1:
            pass
        elif 'now' == val:
            tm = localtime()
            hr = tm[3]
            mi = tm[4]
        elif 'noon' == val:
            hr = 12
        elif len(val) < 3:
            hr = int(val)
            if not amflag and not pmflag and hr < 7:
                hr += 12
        elif len(val) < 5:
            hr = int(val[:-2])
            mi = int(val[-2:])
        else:
            hr = int(val[:1])
    if amflag and hr >= 12:
        hr = hr - 12
    if pmflag and hr < 12:
        hr = hr + 12
    return time(hr, mi) 
开发者ID:linuxscout,项目名称:mishkal,代码行数:39,代码来源:datetimeutil.py

示例15: strtobool

# 需要导入模块: import string [as 别名]
# 或者: from string import lower [as 别名]
def strtobool (val):
    """Convert a string representation of truth to true (1) or false (0).

    True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values
    are 'n', 'no', 'f', 'false', 'off', and '0'.  Raises ValueError if
    'val' is anything else.
    """
    val = string.lower(val)
    if val in ('y', 'yes', 't', 'true', 'on', '1'):
        return 1
    elif val in ('n', 'no', 'f', 'false', 'off', '0'):
        return 0
    else:
        raise ValueError, "invalid truth value %r" % (val,) 
开发者ID:glmcdona,项目名称:meddle,代码行数:16,代码来源:util.py


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