shiyouroc 发表于 2022-3-15 14:27:36

自动密码生成器v2.9.5

本帖最后由 shiyouroc 于 2022-11-26 13:53 编辑

问题;
1.空格太多。
2,函数名是乱的,因为我英文不好。
解决;
1.加注释
2.去bug
# coding=utf-8
#!/usr/bin/python
# Write Python 3 code in this online editor and run it.
from random import randint
from sys import exit
yes = 1#设全局变量

ye = 1#设全局变量

xiao=['a','b','c','d','e','f',
          'g','h','i','j','k','l',         
          'm','n','o','q','p','r',
          't','s','u','v','w','x','y',
          'z']


da =

def three_engling():
   
    global yes#把全局变量转为局部变量
    global ye   #把全局变量转为局部变量
    yes = input("是1退0")
    ye = yes.isdigit()   #判断字符串是否是数字,是ture 否flase
    print(ye)   #打印判断结果

def dcdy():

    global yes
   
    ffff = len(yes)
    if ffff > 2:
      print('请勿非法输入。')
      cc()      

def tt():
    global yes   #把全局变量转为局部变量
    global ye   #把全局变量转为局部变量
   
    while ye == False:
      print('请勿非法输入。')
      yes = input("是1退0")
      ye = yes.isdigit()
      if ye == False:
            cc()
      else:
            break


def dd():
    global yes   #把全局变量转为局部变量
    yes = int(yes)
    if yes > 1:
      print('请勿非法输入。')
      cc()
   
    if yes ==0:
      exit(0)


def sc():
    y=randint(0,2)   #选前三个字母的其中一个字母为小写

   

    if y==0:    #如果为零第一个字母为小写

      d=randint(0,25)

      one=xiao

    else:

      d = randint(0,25)

      one = da

               

    if y==1:#如果为1第一个字母为小写

      q= randint(0,25)

      two = xiao

    else:

      q = randint(0,25)
      two = da

               
    if y==2:    #如果为2第一个字母为小写

      z=randint(0,25)

      three=xiao

    else:

      z=randint(0,25)
      three=da

   

    numbers = randint(1000000,99999999)
    g=str(one)+str(two)+str(three)+'.'+str(numbers)
    print(g)
    cc()
   



   

def cc():
    three_engling()
    dcdy()

    tt()
    dd()
    sc()
   
cc()


@nizitao @python爱好者.
页: [1] 2
查看完整版本: 自动密码生成器v2.9.5