random - 如何纠正 TypeError 与选择()缺少 1 个必需的位置参数:“人口”
问题描述
我希望在调用随机页面函数时显示条目列表,但我不断收到此错误选择()缺少 1 个必需的位置参数:“人口”。
解决方案
我最近因为一个错字而遇到了这个问题。
显然,您使用的是推荐的“秘密”PNG,而不是“随机”伪PNG。我有以下代码:
#!/usr/bin/python3
"""
Will get 10 random letters...
from the lowercase abcdefghijklmnopqrstuvwxyz
"""
import string
import secrets
response = secrets.SystemRandom.choices(string.ascii_lowercase, k=10)
print(response)
但是 secrets.SystemRandom 是一个类,所以我只是将其更改为 secrets.SystemRandom() 并且问题已解决。
固定代码:
#!/usr/bin/python3
"""
Will get 10 random letters...
from the lowercase abcdefghijklmnopqrstuvwxyz
"""
import string
import secrets
response = secrets.SystemRandom().choices(string.ascii_lowercase, k=10)
print(response)
推荐阅读
- javascript - 如何将单词和数字放入用 CanvasJs 制作的图表的条形中?
- c# - 包含自引用子项的查询表
- python - Discord.py 如何让我的机器人在没有“播放”的情况下显示活动
- c# - 如何使更改立即出现在用户界面中?
- google-cloud-dataflow - Apache Beam 中的顺序执行 - Java SDK 2.18.0
- coldfusion - Coldfusion 10 CFchart 标签正在合并条形图
- sql - 更新缺失值
- java - 构建失败:org.codehaus.groovy.control.MultipleCompilationErrorsException
- css - 在引导模式中显示按钮和标题
- python - 正则表达式消除除一个之外的所有主题标签