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


Python builtins.input方法代码示例

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


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

示例1: password

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import input [as 别名]
def password(ctx):
    """
    Change the router admin password.
    """
    url = ctx.obj['base_url'] + "/password/change"

    username = builtins.input("Username: ")
    while True:
        password = getpass.getpass("New password: ")
        confirm = getpass.getpass("Confirm password: ")

        if password == confirm:
            break
        else:
            print("Passwords do not match.")

    data = {
        "username": username,
        "password": password
    }
    router_request("POST", url, json=data) 
开发者ID:ParadropLabs,项目名称:Paradrop,代码行数:23,代码来源:device.py

示例2: set_password

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import input [as 别名]
def set_password(ctx):
    """
    Change the local admin password.

    Set the password required by `pdtools node login` and the local
    web-based administration page.
    """
    username = builtins.input("Username: ")
    while True:
        password = getpass.getpass("New password: ")
        confirm = getpass.getpass("Confirm password: ")

        if password == confirm:
            break
        else:
            print("Passwords do not match.")

    click.echo("Next, if prompted, you should enter the current username and password.")
    client = ctx.obj['client']
    result = client.set_password(username, password)
    click.echo(util.format_result(result))
    return result 
开发者ID:ParadropLabs,项目名称:Paradrop,代码行数:24,代码来源:node.py

示例3: get_token

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import input [as 别名]
def get_token(self):
        url_parts = urlparse(self.auth_url)

        print("Attempting to log in to authentication domain {}".format(url_parts.netloc))
        self.username = builtins.input("Username: ")
        password = getpass.getpass("Password: ")

        data = {
            self.param_map['username']: self.username,
            self.param_map['password']: password
        }
        res = requests.post(self.auth_url, json=data)
        try:
            data = res.json()
            self.token = data['token']
            return self.token
        except:
            return None 
开发者ID:ParadropLabs,项目名称:Paradrop,代码行数:20,代码来源:token_provider.py

示例4: get_class

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import input [as 别名]
def get_class(self, class_name):
        """
        Return the :class:`DvClass` with the given name

        The name is partially matched against the known class names and the first result is returned.
        For example, the input `foobar` will match on Lfoobar/bla/foo;

        :param str class_name:
        :return: the class matching on the name
        :rtype: DvClass
        """
        for name, klass in self.classes.items():
            # TODO why use the name partially?
            if class_name in name:
                if isinstance(klass, DvClass):
                    return klass
                dvclass = self.classes[name] = DvClass(klass, self.vma)
                return dvclass 
开发者ID:amimo,项目名称:dcc,代码行数:20,代码来源:decompile.py

示例5: protect

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import input [as 别名]
def protect(protect_args=None):
    global c
    flags = ''
    option_end = False
    if not protect_args:
        protect_args = argv[1:]
    for arg in protect_args:
        if arg == '--':
            option_end = True
        elif (arg.startswith("-") and not option_end):
            flags = flags + arg[arg.rfind('-') + 1:]
        elif arg in c.invalid:
            pprint('"." and ".." may not be protected')
        else:
            path = abspath(expv(expu(arg)))
            evalpath = dirname(path) + "/." + basename(path) + c.suffix
            if not exists(path):
                pprint("Warning: " + path + " does not exist")
            with open(evalpath, "w") as f:
                question = input("Question for " + path + ": ")
                answer = input("Answer: ")
                f.write(question + "\n" + answer + "\n" + flags.upper()) 
开发者ID:alanzchen,项目名称:rm-protection,代码行数:24,代码来源:protect.py

示例6: username

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import input [as 别名]
def username(self):
        """
        str: Some services require authentication in order to connect to the
        service, in which case the appropriate username can be specified. If not
        specified at instantiation, your local login name will be used. If `True`
        was provided, you will be prompted to type your username at runtime as
        necessary. If `False` was provided, then `None` will be returned. You can
        specify a different username at runtime using: `duct.username = '<username>'`.
        """
        if self._username is True:
            if 'username' not in self.__cached_auth:
                self.__cached_auth['username'] = input("Enter username for '{}':".format(self.name))
            return self.__cached_auth['username']
        elif self._username is False:
            return None
        elif not self._username:
            try:
                username = os.getlogin()
            except OSError:
                username = pwd.getpwuid(os.geteuid()).pw_name
            return username
        return self._username 
开发者ID:airbnb,项目名称:omniduct,代码行数:24,代码来源:duct.py

示例7: request_input

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import input [as 别名]
def request_input(valid_values, prompt=None, max_suggested=3):
    def wrong_input_message():
        print("Invalid answer, only {}{} allowed\n".format(
                ", ".join(valid_values[:max_suggested]),
                ",..." if len(valid_values) > max_suggested else ""))

    while True:
        try:
            input_value = input(prompt) if prompt else input()
            if input_value not in valid_values:
                wrong_input_message()
                continue
        except ValueError:
            wrong_input_message()
            continue
        return input_value 
开发者ID:Rowl1ng,项目名称:rasa_wechat,代码行数:18,代码来源:utils.py

示例8: prompt_edit

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import input [as 别名]
def prompt_edit(req):
    """Prompt user to obtain data to request"""
    name = input("Name of the user you want to modify: ")

    if req.show("user", {"<name>": name}) == 0:
        new_name = input("New name: ")
        new_sshkey = input("New SSH key: ")
        new_comment = input("New comment: ")
        if len(new_comment.strip()) == 0:
            answer = input("Remove original comment? [y/N]")
            if answer == "y":
                new_comment = "PASSHPORTREMOVECOMMENT"

        return {"<name>": name,
                "--newname": new_name,
                "--newsshkey": new_sshkey,
                "--newcomment": new_comment}

    return None 
开发者ID:LibrIT,项目名称:passhport,代码行数:21,代码来源:user.py

示例9: prompt_edit

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import input [as 别名]
def prompt_edit(req):
    """Prompt targetgroup to obtain data to request"""
    name = input("Name of the targetgroup you want to modify: ")

    if req.show("targetgroup", {"<name>": name}) == 0:
        new_name = input("New name: ")
        new_comment = input("New comment: ")
        if len(new_comment.strip()) == 0:
            answer = input("Remove original comment? [y/N]")
            if answer == "y":
                new_comment = "PASSHPORTREMOVECOMMENT"

        return {"<name>": name,
                "--newname": new_name,
                "--newcomment": new_comment}

    return None 
开发者ID:LibrIT,项目名称:passhport,代码行数:19,代码来源:targetgroup.py

示例10: ask_confirmation

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import input [as 别名]
def ask_confirmation(prompt_confirmation):
    """Same as input() but check if user key in a correct input,
    return True if the user confirms, false otherwise.
    """
    # Hack for the sake of compatibility between 2.7 and 3.4
    sys.stdout.write(prompt_confirmation)
    confirmation = str.upper(input(""))

    # Loop until user types [y/N]
    while confirmation != "Y" and confirmation != "N" and confirmation:
        print("You didn't type 'Y' or 'N', please try again.")
        sys.stdout.write(prompt_confirmation)
        confirmation = str.upper(input(""))

    if confirmation == "Y":
        return True

    return False 
开发者ID:LibrIT,项目名称:passhport,代码行数:20,代码来源:requests_functions.py

示例11: prompt_edit

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import input [as 别名]
def prompt_edit(req):
    """Prompt usergroup to obtain data to request"""
    name = input("Name of the usergroup you want to modify: ")

    if req.show("usergroup", {"<name>": name}) == 0:
        new_name = input("New name: ")
        new_comment = input("New comment: ")
        if len(new_comment.strip()) == 0:
            answer = input("Remove original comment? [y/N]")
            if answer == "y":
                new_comment = "PASSHPORTREMOVECOMMENT"


        return {"<name>": name,
                "--newname": new_name,
                "--newcomment": new_comment}

    return None 
开发者ID:LibrIT,项目名称:passhport,代码行数:20,代码来源:usergroup.py

示例12: update_bibs_in

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import input [as 别名]
def update_bibs_in(grouped_bibs, db_abbrev):
    actions = {
        "y": lambda items: [update_in(bibs, db_abbrev) for bibs in items],
        "m": lambda items: [manual_update_in(bibs, db_abbrev) for bibs in items],
        "n": lambda items: items
    }
    print("\n ")
    action = input("Abbreviate everything?" +
                   "y(yes, automatic)/m(manual)/n(do nothing)")
    grouped_bibs.sort(key=operator.itemgetter('journal'))
    grouped_by_journal = []
    for key, items in groupby(grouped_bibs, lambda i: i["journal"]):
        grouped_by_journal.append(list(items))

    if action in ("y", "m", "n"):
        updated_bibs = actions.get(action)(grouped_by_journal)
    else:
        return update_bibs_in(grouped_bibs, db_abbrev)

    updated_bibs = reduce(lambda a, b: a+b, updated_bibs)
    return updated_bibs 
开发者ID:bibcure,项目名称:bibcure,代码行数:23,代码来源:in_db.py

示例13: update_out

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import input [as 别名]
def update_out(bibs, db_abbrev):
    is_abreviation = input(
        "'{}' is a abreviation?y(yes)n(no): ".format(bibs[0]["journal"])
    )
    if is_abreviation == "y":
        full_name = input("Insert journal name:\n")
        abreviation = bibs[0]["journal"]
    elif is_abreviation == "n":
        abreviation = input("Insert abreviation:\n")
        full_name = bibs[0]["journal"]
    else:
        return update_out(bibs, db_abbrev)
    db_abbrev.insert(full_name, abreviation)
    for i, bib in enumerate(bibs):
        bibs[i]["journal"] = abreviation
    return bibs 
开发者ID:bibcure,项目名称:bibcure,代码行数:18,代码来源:out_db.py

示例14: shell

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import input [as 别名]
def shell(url,f):

    while True:
        headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'}
        cmd=input("$ ")
        payload={'cmd':cmd}
        if cmd=="q" or cmd=="Q":
            break

        re=requests.get(str(url)+"/"+str(f),params=payload,headers=headers)
        re=str(re.content)
        t=removetags(re)
        print(t)





#print bcolors.HEADER+ banner+bcolors.ENDC 
开发者ID:swisskyrepo,项目名称:PayloadsAllTheThings,代码行数:21,代码来源:Tomcat CVE-2017-12617.py

示例15: runBatchFpropWithGivenInput

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import input [as 别名]
def runBatchFpropWithGivenInput(hidden_size, X):
        """
        run the LSTM model through the given input data. The data has dimension
        (seq_len, batch_size, hidden_size)

        """
        # seq_len = X.shape[0]
        # batch_size = X.shape[1]
        input_size = X.shape[2]

        WLSTM = LSTM.init(input_size, hidden_size)

        # batch forward
        Hout, cprev, hprev, batch_cache = LSTM.forward(X, WLSTM)

        IFOGf = batch_cache['IFOGf']
        Ct = batch_cache['Ct']

        return Hout, IFOGf, Ct, batch_cache 
开发者ID:NervanaSystems,项目名称:ngraph-python,代码行数:21,代码来源:lstm_ref.py


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