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


Python string.strip方法代码示例

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


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

示例1: print_requests_config

# 需要导入模块: import string [as 别名]
# 或者: from string import strip [as 别名]
def print_requests_config(name, stats):
    print("multigraph mxruntime_requests_%s" % name)
    print("graph_args --base 1000 -l 0")
    print("graph_vlabel Requests per second")
    print("graph_title %s - MxRuntime Requests" % name)
    print("graph_category Mendix")
    print(
        "graph_info This graph shows the amount of requests this MxRuntime handles"
    )
    for sub in stats["requests"].keys():
        substrip = "_" + string.strip(sub, "/").replace("-", "_")
        if sub != "":
            subname = sub
        else:
            subname = "/"
        print("%s.label %s" % (substrip, subname))
        print("%s.draw LINE1" % substrip)
        print(
            "%s.info amount of requests this MxRuntime handles on %s"
            % (substrip, subname)
        )
        print("%s.type DERIVE" % substrip)
        print("%s.min 0" % substrip)
    print("") 
开发者ID:mendix,项目名称:cf-mendix-buildpack,代码行数:26,代码来源:munin.py

示例2: _format_changelog

# 需要导入模块: import string [as 别名]
# 或者: from string import strip [as 别名]
def _format_changelog(self, changelog):
        """Format the changelog correctly and convert it to a list of strings
        """
        if not changelog:
            return changelog
        new_changelog = []
        for line in string.split(string.strip(changelog), '\n'):
            line = string.strip(line)
            if line[0] == '*':
                new_changelog.extend(['', line])
            elif line[0] == '-':
                new_changelog.append(line)
            else:
                new_changelog.append('  ' + line)

        # strip trailing newline inserted by first changelog entry
        if not new_changelog[0]:
            del new_changelog[0]

        return new_changelog

    # _format_changelog()

# class bdist_rpm 
开发者ID:glmcdona,项目名称:meddle,代码行数:26,代码来源:bdist_rpm.py

示例3: source_synopsis

# 需要导入模块: import string [as 别名]
# 或者: from string import strip [as 别名]
def source_synopsis(file):
    line = file.readline()
    while line[:1] == '#' or not strip(line):
        line = file.readline()
        if not line: break
    line = strip(line)
    if line[:4] == 'r"""': line = line[1:]
    if line[:3] == '"""':
        line = line[3:]
        if line[-1:] == '\\': line = line[:-1]
        while not strip(line):
            line = file.readline()
            if not line: break
        result = strip(split(line, '"""')[0])
    else: result = None
    return result 
开发者ID:glmcdona,项目名称:meddle,代码行数:18,代码来源:pydoc.py

示例4: _syscmd_uname

# 需要导入模块: import string [as 别名]
# 或者: from string import strip [as 别名]
def _syscmd_uname(option,default=''):

    """ Interface to the system's uname command.
    """
    if sys.platform in ('dos','win32','win16','os2'):
        # XXX Others too ?
        return default
    try:
        f = os.popen('uname %s 2> %s' % (option, DEV_NULL))
    except (AttributeError,os.error):
        return default
    output = string.strip(f.read())
    rc = f.close()
    if not output or rc:
        return default
    else:
        return output 
开发者ID:glmcdona,项目名称:meddle,代码行数:19,代码来源:platform.py

示例5: help

# 需要导入模块: import string [as 别名]
# 或者: from string import strip [as 别名]
def help(self, request):
        if type(request) is type(''):
            request = request.strip()
            if request == 'help': self.intro()
            elif request == 'keywords': self.listkeywords()
            elif request == 'symbols': self.listsymbols()
            elif request == 'topics': self.listtopics()
            elif request == 'modules': self.listmodules()
            elif request[:8] == 'modules ':
                self.listmodules(split(request)[1])
            elif request in self.symbols: self.showsymbol(request)
            elif request in self.keywords: self.showtopic(request)
            elif request in self.topics: self.showtopic(request)
            elif request: doc(request, 'Help on %s:')
        elif isinstance(request, Helper): self()
        else: doc(request, 'Help on %s:')
        self.output.write('\n') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:19,代码来源:pydoc.py

示例6: ParseResolvConf

# 需要导入模块: import string [as 别名]
# 或者: from string import strip [as 别名]
def ParseResolvConf(resolv_path):
    global defaults
    try:
        lines = open(resolv_path).readlines()
    except:
        print "error in path" + resolv_path
    for line in lines:
        line = string.strip(line)
        if not line or line[0] == ';' or line[0] == '#':
            continue
        fields = string.split(line)
        if len(fields) < 2:
            continue
        if fields[0] == 'domain' and len(fields) > 1:
            defaults['domain'] = fields[1]
        if fields[0] == 'search':
            pass
        if fields[0] == 'options':
            pass
        if fields[0] == 'sortlist':
            pass
        if fields[0] == 'nameserver':
            defaults['server'].append(fields[1]) 
开发者ID:Yukinoshita47,项目名称:Yuki-Chan-The-Auto-Pentest,代码行数:25,代码来源:Base.py

示例7: search_filename

# 需要导入模块: import string [as 别名]
# 或者: from string import strip [as 别名]
def search_filename(filename, languages):
  title, year = xbmc.getCleanMovieTitle(filename)
  log(__name__, "clean title: \"%s\" (%s)" % (title, year))
  try:
    yearval = int(year)
  except ValueError:
    yearval = 0
  if title and yearval > 1900:
    query_Film(title, year, item['3let_language'], filename)
  else:
    match = re.search(r'\WS(?P<season>\d\d)E(?P<episode>\d\d)', title, flags=re.IGNORECASE)
    if match is not None:
      tvshow = string.strip(title[:match.start('season')-1])
      season = string.lstrip(match.group('season'), '0')
      episode = string.lstrip(match.group('episode'), '0')
      query_TvShow(tvshow, season, episode, item['3let_language'], filename)
    else:
      search_manual(filename, item['3let_language'], filename) 
开发者ID:cflannagan,项目名称:service.subtitles.addic7ed,代码行数:20,代码来源:service.py

示例8: __init__

# 需要导入模块: import string [as 别名]
# 或者: from string import strip [as 别名]
def __init__(self, pos, offset, line):
        "Initialize the synset from a line off a WN synset file."
	self.pos = pos
        "part of speech -- one of NOUN, VERB, ADJECTIVE, ADVERB."
	self.offset = offset
        """integer offset into the part-of-speech file.  Together
        with pos, this can be used as a unique id."""
	tokens = string.split(line[:string.index(line, '|')])
	self.ssType = tokens[2]
	self.gloss = string.strip(line[string.index(line, '|') + 1:])
        self.lexname = Lexname.lexnames[int(tokens[1])]
	(self._senseTuples, remainder) = _partition(tokens[4:], 2, string.atoi(tokens[3], 16))
	(self._pointerTuples, remainder) = _partition(remainder[1:], 4, int(remainder[0]))
	if pos == VERB:
	    (vfTuples, remainder) = _partition(remainder[1:], 3, int(remainder[0]))
	    def extractVerbFrames(index, vfTuples):
		return tuple(map(lambda t:string.atoi(t[1]), filter(lambda t,i=index:string.atoi(t[2],16) in (0, i), vfTuples)))
	    senseVerbFrames = []
	    for index in range(1, len(self._senseTuples) + 1):
		senseVerbFrames.append(extractVerbFrames(index, vfTuples))
	    self._senseVerbFrames = senseVerbFrames
	    self.verbFrames = tuple(extractVerbFrames(None, vfTuples))
            """A sequence of integers that index into
            VERB_FRAME_STRINGS. These list the verb frames that any
            Sense in this synset participates in.  (See also
            Sense.verbFrames.) Defined only for verbs.""" 
开发者ID:rafasashi,项目名称:razzy-spinner,代码行数:28,代码来源:wordnet.py

示例9: encrypt

# 需要导入模块: import string [as 别名]
# 或者: from string import strip [as 别名]
def encrypt( self ):
      """Encrypt a text"""

      # get text from Text component
      text = self.text1.get( 1.0, END )
      text = string.strip( text )

      # encrypt text
      encryptedText = self.ciper.encrypt( text )
      self.text1.delete( 1.0, END )

      # display encrypted text
      self.text1.insert( END, encryptedText ) 
开发者ID:PythonClassRoom,项目名称:PythonClassBook,代码行数:15,代码来源:fig21_01.py

示例10: decrypt

# 需要导入模块: import string [as 别名]
# 或者: from string import strip [as 别名]
def decrypt( self ):
      """Decrypt a text"""

      # get text from Text component
      text = self.text1.get( 1.0, END )
      text = string.strip( text )

      # decrypt text
      decryptedText = self.ciper.decrypt( text )
      self.text1.delete( 1.0, END )

      # display decrypted text
      self.text1.insert( END, decryptedText ) 
开发者ID:PythonClassRoom,项目名称:PythonClassBook,代码行数:15,代码来源:fig21_01.py

示例11: parse_timedelta

# 需要导入模块: import string [as 别名]
# 或者: from string import strip [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

示例12: print_requests_values

# 需要导入模块: import string [as 别名]
# 或者: from string import strip [as 别名]
def print_requests_values(name, stats):
    print("multigraph mxruntime_requests_%s" % name)
    for sub, count in stats["requests"].items():
        substrip = "_" + string.strip(sub, "/").replace("-", "_")
        print("%s.value %s" % (substrip, count))
    print("") 
开发者ID:mendix,项目名称:cf-mendix-buildpack,代码行数:8,代码来源:munin.py

示例13: splitdoc

# 需要导入模块: import string [as 别名]
# 或者: from string import strip [as 别名]
def splitdoc(doc):
    """Split a doc string into a synopsis line (if any) and the rest."""
    lines = split(strip(doc), '\n')
    if len(lines) == 1:
        return lines[0], ''
    elif len(lines) >= 2 and not rstrip(lines[1]):
        return lines[0], join(lines[2:], '\n')
    return '', join(lines, '\n') 
开发者ID:glmcdona,项目名称:meddle,代码行数:10,代码来源:pydoc.py

示例14: interact

# 需要导入模块: import string [as 别名]
# 或者: from string import strip [as 别名]
def interact(self):
        self.output.write('\n')
        while True:
            try:
                request = self.getline('help> ')
                if not request: break
            except (KeyboardInterrupt, EOFError):
                break
            request = strip(replace(request, '"', '', "'", ''))
            if lower(request) in ('q', 'quit'): break
            self.help(request) 
开发者ID:glmcdona,项目名称:meddle,代码行数:13,代码来源:pydoc.py

示例15: showtopic

# 需要导入模块: import string [as 别名]
# 或者: from string import strip [as 别名]
def showtopic(self, topic, more_xrefs=''):
        try:
            import pydoc_data.topics
        except ImportError:
            self.output.write('''
Sorry, topic and keyword documentation is not available because the
module "pydoc_data.topics" could not be found.
''')
            return
        target = self.topics.get(topic, self.keywords.get(topic))
        if not target:
            self.output.write('no documentation found for %s\n' % repr(topic))
            return
        if type(target) is type(''):
            return self.showtopic(target, more_xrefs)

        label, xrefs = target
        try:
            doc = pydoc_data.topics.topics[label]
        except KeyError:
            self.output.write('no documentation found for %s\n' % repr(topic))
            return
        pager(strip(doc) + '\n')
        if more_xrefs:
            xrefs = (xrefs or '') + ' ' + more_xrefs
        if xrefs:
            import StringIO, formatter
            buffer = StringIO.StringIO()
            formatter.DumbWriter(buffer).send_flowing_data(
                'Related help topics: ' + join(split(xrefs), ', ') + '\n')
            self.output.write('\n%s\n' % buffer.getvalue()) 
开发者ID:glmcdona,项目名称:meddle,代码行数:33,代码来源:pydoc.py


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