python - 如何使python输出不带括号的文本?
问题描述
我正在 python 中创建用户名和密码生成器,当我想打印时pwrd
,例如设置uchoice
它hello
会结束,因为('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 - 如何检测上半身从肩部到肚脐点?
- python - sample_distorted_bounding_box() 至少需要 2 个参数(给定 3 个)
- c++ - 具有意外结果的 c++ 闭包
- c# - WebApi 中的浏览器
- reactjs - 变量上的reactstrap轮播html标签
- android - 错误:运算符 (!=) 不能应用于 double,"null" 。怎么修?
- java - 通过在相对布局(或线性布局)中从下到上添加按钮来增加滚动视图
- java - 创建的文件在 Eclipse 中保存在哪里?未找到新文件异常?
- c - 在 C 中写入指针数组
- php - 如何在不使用循环的情况下将数组拆分为两个不同的数组?