當前位置: 首頁>>代碼示例>>Python>>正文


Python __builtin__.input方法代碼示例

本文整理匯總了Python中__builtin__.input方法的典型用法代碼示例。如果您正苦於以下問題:Python __builtin__.input方法的具體用法?Python __builtin__.input怎麽用?Python __builtin__.input使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在__builtin__的用法示例。


在下文中一共展示了__builtin__.input方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: check_samples

# 需要導入模塊: import __builtin__ [as 別名]
# 或者: from __builtin__ import input [as 別名]
def check_samples(samples=()):
    """
      Check script output for all samples. Sample is a two element list, where the first is input and
      the second is output.
    """
    for sample in samples:
        if len(sample) == 2:
            output = get_file_output(arg_string=str(sample[0]))
            if "\n".join(output) != sample[1]:
                failed(
                    "Test from samples failed: \n \n"
                    "Input:\n{}"
                    "\n \n"
                    "Expected:\n{}"
                    "\n \n"
                    "Your result:\n{}".format(str.strip(sample[0]), str.strip(sample[1]), "\n".join(output)))
                return
        set_congratulation_message("All test from samples passed. Now we are checking your solution on Stepic server.")

    passed() 
開發者ID:jetbrains-academy,項目名稱:pycharm-courses,代碼行數:22,代碼來源:test_helper.py

示例2: patch_input

# 需要導入模塊: import __builtin__ [as 別名]
# 或者: from __builtin__ import 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

示例3: revert_input

# 需要導入模塊: import __builtin__ [as 別名]
# 或者: from __builtin__ import 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

示例4: _raw_input

# 需要導入模塊: import __builtin__ [as 別名]
# 或者: from __builtin__ import 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: input

# 需要導入模塊: import __builtin__ [as 別名]
# 或者: from __builtin__ import 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

示例6: input

# 需要導入模塊: import __builtin__ [as 別名]
# 或者: from __builtin__ import input [as 別名]
def input(prompt=''):
        return builtin_mod.input(prompt) 
開發者ID:luckystarufo,項目名稱:pySINDy,代碼行數:4,代碼來源:py3compat.py

示例7: input

# 需要導入模塊: import __builtin__ [as 別名]
# 或者: from __builtin__ import input [as 別名]
def input(*args, **kwargs):
        if _coconut.hasattr(_coconut_sys.stdout, "encoding") and _coconut_sys.stdout.encoding is not None:
            return _coconut_raw_input(*args, **kwargs).decode(_coconut_sys.stdout.encoding)
        return _coconut_raw_input(*args, **kwargs).decode() 
開發者ID:evhub,項目名稱:pyprover,代碼行數:6,代碼來源:__coconut__.py

示例8: raw_input

# 需要導入模塊: import __builtin__ [as 別名]
# 或者: from __builtin__ import 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

示例9: raw_input

# 需要導入模塊: import __builtin__ [as 別名]
# 或者: from __builtin__ import 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

示例10: input

# 需要導入模塊: import __builtin__ [as 別名]
# 或者: from __builtin__ import 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

示例11: enable

# 需要導入模塊: import __builtin__ [as 別名]
# 或者: from __builtin__ import 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

示例12: disable

# 需要導入模塊: import __builtin__ [as 別名]
# 或者: from __builtin__ import input [as 別名]
def disable():
	builtins.raw_input = original_raw_input
	builtins.input = original_input 
開發者ID:Drekin,項目名稱:win-unicode-console,代碼行數:5,代碼來源:raw_input.py

示例13: InitPil

# 需要導入模塊: import __builtin__ [as 別名]
# 或者: from __builtin__ import input [as 別名]
def InitPil():
    """
    Initialize PIL's Image module.
    """
    import PIL.Image
    import PIL.PngImagePlugin
    import PIL.JpegImagePlugin
    import PIL.BmpImagePlugin
    import PIL.GifImagePlugin
    PIL.Image._initialized = 2

# replace builtin input() with a small dialog 
開發者ID:EventGhost,項目名稱:EventGhost,代碼行數:14,代碼來源:Init.py


注:本文中的__builtin__.input方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。