Home
Categories
WIKI
Topic
User
LANGUAGE:
中文
English
这个操作尴尬了!!!
Experiences and Insight
294
views ·
0
replies ·
To
floor
Go
lgaying
deepin
2018-11-29 06:14
Author
本帖最后由 lgaying 于 2018-11-28 22:37 编辑
Copy the Code
author: Gray
date: 2018-11-28
环境:Deepin15.8 Python3
一个自定义位数密码的Demo
需要用到的Python库 random , string
旨在了解掌握其方法的使用
'''
import random,string #导入random,string
a=string.ascii_letters+string.digits #定义字符串a的值(即密码值)
key = [] #定义一个空列表,存储生成的密码
def password(): #定义函数名字为 password
key = random.sample(a,pwd_num) #从字符串 a 中随机选取 自定义位数的字符
keys = "".join(key) #把随机生成的N个字符串拼接为一个字符串
return keys #返回值
username = input("请输入你的名字:") #引导用户输入名字
pwd_num = int(input("请输入你要生成密码的位数:")) #引导用户输入想生成多少位的密码
print ("%s,你需要生成的%d位的密码是:%s" %(username,pwd_num,password())) #把生成的密码输出到屏幕上
Copy the Code
代码和执行图如上。额小白一个,最近在学习Python。
同样的代码,同样的工具在Win平台下是OK的,在deepin终端下也是OK的,但在sublime Text3下,却尴尬了。
我想知道这是系统还是工具或是插件的原因?
Reply
Like 0
Favorite
View the author
All Replies
No replies yet
Please
sign
in first
Featured Collection
Change
[Tutorial] deepin25 WSL Offline Installation Guide
UOS AI 2.8 Released! Three New Intelligent Agents & Major Evolution
Solid Q&A | deepin 25 Common Questions – The Immutable System Edition
New Thread
Popular Ranking
Change
Update driver for my computer
Copying folder - Not enough disk space?
Popular Events
More
代码和执行图如上。额小白一个,最近在学习Python。
同样的代码,同样的工具在Win平台下是OK的,在deepin终端下也是OK的,但在sublime Text3下,却尴尬了。
我想知道这是系统还是工具或是插件的原因?