Python 3.4显示print是无效语法

时间:2017-04-13 01:49:44

标签: python

import string
from random import *
characters = string.ascii_letters+strings.punctuation+string.digits
password = "".join(choice(characters) for x in range(randint(8,16))
print(password)

打印显示为无效语法。我正在尝试制作随机密码生成器。我做错了什么?

1 个答案:

答案 0 :(得分:-1)

你错过了前一行的右括号。

password = "".join(choice(characters) for x in range(randint(8,16)))

当你处于此状态时,在此之前修正错误 - 它是string.punctuation而不是strings.punctuation