當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。