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


Python string.rstrip方法代码示例

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


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

示例1: look_for_pythondoc

# 需要导入模块: import string [as 别名]
# 或者: from string import rstrip [as 别名]
def look_for_pythondoc(self, type, token, start, end, line):
        if type == tokenize.COMMENT and string.rstrip(token) == "##":
            # found a comment: set things up for comment processing
            self.comment_start = start
            self.comment = []
            return self.process_comment_body
        else:
            # deal with "bare" subjects
            if token == "def" or token == "class":
                self.subject_indent = self.indent
                self.subject_parens = 0
                self.subject_start = self.comment_start = None
                self.subject = []
                return self.process_subject(type, token, start, end, line)
            return self.look_for_pythondoc

    ##
    # (Token handler) Processes a comment body.  This handler adds
    # comment lines to the current comment. 
开发者ID:alexfeng,项目名称:InternationalizationScript-iOS,代码行数:21,代码来源:pythondoc.py

示例2: getsites

# 需要导入模块: import string [as 别名]
# 或者: from string import rstrip [as 别名]
def getsites(lang):
	try:
                page_counter=0
    		while page_counter < int(arg_page_end):
                        s.send("PONG %s\r\n" % line[1]) 
			time.sleep(3)
                        results_web = 'http://www.google.com/search?q='+str(query)+'&hl='+str(lang)+'&lr=&ie=UTF-8&start='+repr(page_counter)+'&sa=N'
        		request_web = urllib2.Request(results_web)
        		request_web.add_header('User-Agent',random.choice(agents))
        		opener_web = urllib2.build_opener()
        		text = opener_web.open(request_web).read()
                        if re.search("403 Forbidden", text):
                                s.send("PRIVMSG %s :%s\r\n" % (CHAN, "[-] Received Captcha... Damn that sucks!"))
                                break
        		names = re.findall(('<cite>+[\w\d\?\/\.\=\s\-]+=+[\d]+[\w\d\?\/\.\=\s\-]+</cite>'),text.replace("<b>","").replace("</b>",""))
        		for name in names:
				name = re.sub(" - \d+k - </cite>","",name.replace("<cite>","")).replace("</cite>","")
				name = name.rstrip(" -")
				sites.append(name)
        		page_counter +=10
                                
	except IOError:
		s.send("PRIVMSG %s :%s\r\n" % (CHAN, "[-] Can't connect to Google Web!")) 
开发者ID:knightmare2600,项目名称:d4rkc0de,代码行数:25,代码来源:sqlifinderb0t.py

示例3: visitNode_a_listing

# 需要导入模块: import string [as 别名]
# 或者: from string import rstrip [as 别名]
def visitNode_a_listing(self, node):
        fileName = os.path.join(self.currDir, node.getAttribute('href'))
        self.writer('\\begin{verbatim}\n')
        lines = map(string.rstrip, open(fileName).readlines())
        skipLines = int(node.getAttribute('skipLines') or 0)
        lines = lines[skipLines:]
        self.writer(text.removeLeadingTrailingBlanks('\n'.join(lines)))
        self.writer('\\end{verbatim}')

        # Write a caption for this source listing
        fileName = os.path.basename(fileName)
        caption = domhelpers.getNodeText(node)
        if caption == fileName:
            caption = 'Source listing'
        self.writer('\parbox[b]{\linewidth}{\\begin{center}%s --- '
                    '\\begin{em}%s\\end{em}\\end{center}}'
                    % (latexEscape(caption), latexEscape(fileName))) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:19,代码来源:latex.py

示例4: visitNode_a_listing

# 需要导入模块: import string [as 别名]
# 或者: from string import rstrip [as 别名]
def visitNode_a_listing(self, node):
        fileName = os.path.join(self.currDir, node.getAttribute('href'))
        self.writer('\\begin{verbatim}\n')
        lines = map(string.rstrip, open(fileName).readlines())
        lines = lines[int(node.getAttribute('skipLines', 0)):]
        self.writer(text.removeLeadingTrailingBlanks('\n'.join(lines)))
        self.writer('\\end{verbatim}')

        # Write a caption for this source listing
        fileName = os.path.basename(fileName)
        caption = domhelpers.getNodeText(node)
        if caption == fileName:
            caption = 'Source listing'
        self.writer('\parbox[b]{\linewidth}{\\begin{center}%s --- '
                    '\\begin{em}%s\\end{em}\\end{center}}'
                    % (latexEscape(caption), latexEscape(fileName))) 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:18,代码来源:latex.py

示例5: getdoc

# 需要导入模块: import string [as 别名]
# 或者: from string import rstrip [as 别名]
def getdoc(object):
    """Get the doc string or comments for an object."""
    result = inspect.getdoc(object) or inspect.getcomments(object)
    return result and re.sub('^ *\n', '', rstrip(result)) or '' 
开发者ID:glmcdona,项目名称:meddle,代码行数:6,代码来源:pydoc.py

示例6: splitdoc

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

示例7: getdocloc

# 需要导入模块: import string [as 别名]
# 或者: from string import rstrip [as 别名]
def getdocloc(self, object):
        """Return the location of module docs or None"""

        try:
            file = inspect.getabsfile(object)
        except TypeError:
            file = '(built-in)'

        docloc = os.environ.get("PYTHONDOCS",
                                "http://docs.python.org/library")
        basedir = os.path.join(sys.exec_prefix, "lib",
                               "python"+sys.version[0:3])
        if (isinstance(object, type(os)) and
            (object.__name__ in ('errno', 'exceptions', 'gc', 'imp',
                                 'marshal', 'posix', 'signal', 'sys',
                                 'thread', 'zipimport') or
             (file.startswith(basedir) and
              not file.startswith(os.path.join(basedir, 'site-packages')))) and
            object.__name__ not in ('xml.etree', 'test.pydoc_mod')):
            if docloc.startswith("http://"):
                docloc = "%s/%s" % (docloc.rstrip("/"), object.__name__)
            else:
                docloc = os.path.join(docloc, object.__name__ + ".html")
        else:
            docloc = None
        return docloc

# -------------------------------------------- HTML documentation generator 
开发者ID:glmcdona,项目名称:meddle,代码行数:30,代码来源:pydoc.py

示例8: indent

# 需要导入模块: import string [as 别名]
# 或者: from string import rstrip [as 别名]
def indent(self, text, prefix='    '):
        """Indent text by prepending a given prefix to each line."""
        if not text: return ''
        lines = split(text, '\n')
        lines = map(lambda line, prefix=prefix: prefix + line, lines)
        if lines: lines[-1] = rstrip(lines[-1])
        return join(lines, '\n') 
开发者ID:glmcdona,项目名称:meddle,代码行数:9,代码来源:pydoc.py

示例9: section

# 需要导入模块: import string [as 别名]
# 或者: from string import rstrip [as 别名]
def section(self, title, contents):
        """Format a section with a given heading."""
        return self.bold(title) + '\n' + rstrip(self.indent(contents)) + '\n\n'

    # ---------------------------------------------- type-specific routines 
开发者ID:glmcdona,项目名称:meddle,代码行数:7,代码来源:pydoc.py

示例10: getdoc

# 需要导入模块: import string [as 别名]
# 或者: from string import rstrip [as 别名]
def getdoc(object):
    """Get the doc string or comments for an object."""
    result = inspect.getdoc(object) or inspect.getcomments(object)
    result = _encode(result)
    return result and re.sub('^ *\n', '', rstrip(result)) or '' 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:7,代码来源:pydoc.py

示例11: getdocloc

# 需要导入模块: import string [as 别名]
# 或者: from string import rstrip [as 别名]
def getdocloc(self, object,
                  basedir=os.path.join(sys.exec_prefix, "lib",
                                       "python"+sys.version[0:3])):
        """Return the location of module docs or None"""

        try:
            file = inspect.getabsfile(object)
        except TypeError:
            file = '(built-in)'

        docloc = os.environ.get("PYTHONDOCS",
                                "https://docs.python.org/library")
        basedir = os.path.normcase(basedir)
        if (isinstance(object, type(os)) and
            (object.__name__ in ('errno', 'exceptions', 'gc', 'imp',
                                 'marshal', 'posix', 'signal', 'sys',
                                 'thread', 'zipimport') or
             (file.startswith(basedir) and
              not file.startswith(os.path.join(basedir, 'site-packages')))) and
            object.__name__ not in ('xml.etree', 'test.pydoc_mod')):
            if docloc.startswith(("http://", "https://")):
                docloc = "%s/%s" % (docloc.rstrip("/"), object.__name__.lower())
            else:
                docloc = os.path.join(docloc, object.__name__.lower() + ".html")
        else:
            docloc = None
        return docloc

# -------------------------------------------- HTML documentation generator 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:31,代码来源:pydoc.py

示例12: _update

# 需要导入模块: import string [as 别名]
# 或者: from string import rstrip [as 别名]
def _update(self):
        import string
        self._index = {}
        try:
            f = _open(self._dirfile)
        except IOError:
            pass
        else:
            while 1:
                line = string.rstrip(f.readline())
                if not line:
                    break
                key, (pos, siz) = eval(line)
                self._index[key] = (pos, siz)
            f.close() 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:17,代码来源:_dumbdbm_patched.py


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