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


Python __builtin__.raw_input方法代码示例

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


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

示例1: patch_input

# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import raw_input [as 别名]
def patch_input():
    def mock_fun(_m=""):
        return "mock"

    if sys.version_info[0] == 3:
        import builtins
        save_input = builtins.input
        builtins.input = mock_fun
        return save_input
    elif sys.version_info[0] == 2:
        import __builtin__
        save_input = __builtin__.raw_input
        __builtin__.raw_input = mock_fun
        __builtin__.input = mock_fun
        return save_input 
开发者ID:jetbrains-academy,项目名称:pycharm-courses,代码行数:17,代码来源:test_helper.py

示例2: revert_input

# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import raw_input [as 别名]
def revert_input(saved_input):
    if sys.version_info[0] == 3:
        import builtins
        builtins.input = saved_input
    elif sys.version_info[0] == 2:
        import __builtin__
        __builtin__.raw_input = saved_input
        __builtin__.input = saved_input 
开发者ID:jetbrains-academy,项目名称:pycharm-courses,代码行数:10,代码来源:test_helper.py

示例3: _no_raw_input

# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import raw_input [as 别名]
def _no_raw_input(self):
        """Raise StdinNotImplentedError if active frontend doesn't support
        stdin."""
        raise StdinNotImplementedError("raw_input was called, but this "
                                       "frontend does not support stdin.") 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:7,代码来源:ipkernel.py

示例4: _raw_input

# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import raw_input [as 别名]
def _raw_input(self, prompt, ident, parent):
        # Flush output before making the request.
        sys.stderr.flush()
        sys.stdout.flush()
        # flush the stdin socket, to purge stale replies
        while True:
            try:
                self.stdin_socket.recv_multipart(zmq.NOBLOCK)
            except zmq.ZMQError as e:
                if e.errno == zmq.EAGAIN:
                    break
                else:
                    raise
        
        # Send the input request.
        content = json_clean(dict(prompt=prompt))
        self.session.send(self.stdin_socket, u'input_request', content, parent,
                          ident=ident)

        # Await a response.
        while True:
            try:
                ident, reply = self.session.recv(self.stdin_socket, 0)
            except Exception:
                self.log.warn("Invalid Message:", exc_info=True)
            except KeyboardInterrupt:
                # re-raise KeyboardInterrupt, to truncate traceback
                raise KeyboardInterrupt
            else:
                break
        try:
            value = py3compat.unicode_to_str(reply['content']['value'])
        except:
            self.log.error("Got bad raw_input reply: ")
            self.log.error("%s", parent)
            value = ''
        if value == '\x04':
            # EOF
            raise EOFError
        return value 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:42,代码来源:ipkernel.py

示例5: raw_input

# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import raw_input [as 别名]
def raw_input(prompt=''):
            #the original raw_input would only remove a trailing \n, so, at
            #this point if we had a \r\n the \r would remain (which is valid for eclipse)
            #so, let's remove the remaining \r which python didn't expect.
            ret = original_raw_input(prompt)

            if ret.endswith('\r'):
                return ret[:-1]

            return ret 
开发者ID:fabioz,项目名称:PyDev.Debugger,代码行数:12,代码来源:sitecustomize.py

示例6: input

# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import raw_input [as 别名]
def input(prompt=''):
            #input must also be rebinded for using the new raw_input defined
            return eval(raw_input(prompt)) 
开发者ID:fabioz,项目名称:PyDev.Debugger,代码行数:5,代码来源:sitecustomize.py

示例7: raw_input

# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import raw_input [as 别名]
def raw_input(prompt=None):
    if prompt:
        sys.stdout.write(prompt)
    return builtin_raw_input() 
开发者ID:mazaclub,项目名称:encompass,代码行数:6,代码来源:util.py

示例8: input

# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import raw_input [as 别名]
def input(prompt=''):
        return builtin_mod.raw_input(prompt) 
开发者ID:luckystarufo,项目名称:pySINDy,代码行数:4,代码来源:py3compat.py

示例9: confirm

# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import raw_input [as 别名]
def confirm(self, activity):
        """Prompt, if self.prompt"""
        yes = True
        self.doing = u"importing {}".format(activity)
        if self.prompt:
            yes = False
            inp = input(u"    OK to import {}? (y/n):".format(activity))
            try:
                yes = strtobool(inp)
            except ValueError:
                pass
        if not yes:
            print(u"    Not importing {}".format(activity))
        return yes 
开发者ID:ibmresilient,项目名称:resilient-python-api,代码行数:16,代码来源:resilient_customize.py

示例10: raw_input

# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import raw_input [as 别名]
def raw_input(*args):
        """Coconut uses Python 3 "input" instead of Python 2 "raw_input"."""
        raise _coconut.NameError('Coconut uses Python 3 "input" instead of Python 2 "raw_input"') 
开发者ID:evhub,项目名称:pyprover,代码行数:5,代码来源:__coconut__.py

示例11: raw_input

# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import raw_input [as 别名]
def raw_input(prompt=""):
	"""raw_input([prompt]) -> string

Read a string from standard input.  The trailing newline is stripped.
If the user hits EOF (Unix: Ctl-D, Windows: Ctl-Z+Return), raise EOFError.
On Unix, GNU readline is used if enabled.  The prompt string, if given,
is printed without a trailing newline before reading."""
	
	sys.stderr.flush()
	
	tty = STDIN.is_a_TTY() and STDOUT.is_a_TTY()
	
	if RETURN_UNICODE:
		if tty:
			line_bytes = readline(prompt)
			line = stdin_decode(line_bytes)
		else:
			line = stdio_readline(prompt)
		
	else:
		if tty:
			line = readline(prompt)
		else:
			line_unicode = stdio_readline(prompt)
			line = stdin_encode(line_unicode)
	
	if line:
		return line[:-1] # strip strailing "\n"
	else:
		raise EOFError 
开发者ID:Drekin,项目名称:win-unicode-console,代码行数:32,代码来源:raw_input.py

示例12: input

# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import raw_input [as 别名]
def input(prompt=""):
	"""input([prompt]) -> value

Equivalent to eval(raw_input(prompt))."""
	
	string = stdin_decode(raw_input(prompt))
	
	caller_frame = sys._getframe(1)
	globals = caller_frame.f_globals
	locals = caller_frame.f_locals
	
	return eval(string, globals, locals) 
开发者ID:Drekin,项目名称:win-unicode-console,代码行数:14,代码来源:raw_input.py

示例13: enable

# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import raw_input [as 别名]
def enable(return_unicode=RETURN_UNICODE):
	global RETURN_UNICODE
	RETURN_UNICODE = return_unicode
	
	builtins.raw_input = raw_input
	builtins.input = input 
开发者ID:Drekin,项目名称:win-unicode-console,代码行数:8,代码来源:raw_input.py

示例14: disable

# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import raw_input [as 别名]
def disable():
	builtins.raw_input = original_raw_input
	builtins.input = original_input 
开发者ID:Drekin,项目名称:win-unicode-console,代码行数:5,代码来源:raw_input.py

示例15: Input

# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import raw_input [as 别名]
def Input(prompt=None):
    return eval(eg.SimpleInputDialog.RawInput(prompt))

# replace builtin raw_input() with a small dialog 
开发者ID:EventGhost,项目名称:EventGhost,代码行数:6,代码来源:Init.py


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