首页 > 解决方案 > 如何使python输出不带括号的文本?

问题描述

我正在 python 中创建用户名和密码生成器,当我想打印时pwrd,例如设置uchoicehello会结束,因为('hello', ['m', 'z', 'a', 'b'], ['6', '8', '1', '1'], ['-', '['])有什么方法可以阻止所有这些括号和引号出现在输出中?我试过使用 f 字符串,但这只会让它变得更奇怪。这是代码:

    `def password():
        alphabet = list("abcdefghijklmnopqrstuvwxyz")
        numbers = list("1234567890")
        characters = list("!£$%^&*():;@{}[]#~/?<>.\|-_=+")
        uchoice = input("What is a word you can remember easily?")
        achoice = [random.choice(alphabet) for i in range(4)]
        nchoice = [random.choice(numbers) for u in range(4)]
        cchoice = [random.choice(characters) for x in range(2)]
        pwrd = uchoice,achoice,nchoice,cchoice
        print("Your new password is...")
        time.sleep(1)
        print(".")
        time.sleep(1)
        print("..")
        time.sleep(1)
        print("...")
        time.sleep(2)
        print(pwrd)`

标签: python

解决方案


推荐阅读