如何创建函数以生成具有递增编号的用户

时间:2019-10-11 00:53:19

标签: python-3.7

我正在创建一个python应用程序以生成具有升序数字的行

这是用于运行python3,7的作业,我已经尝试过生成具有递增编号的用户,并且似乎总是以空括号结尾


import random

chars = '1234567890'
usr = input('User to generate : ')
usr = str(usr)

number = input('number of lines : ')
number = int(number)

length = input('password length : ')
length = int(length)

exp = input('expire date : ')
exp = str(exp)

print('\n<xml-user-manager ver="1.0">')

for x in zip(range(number), itertools.count()):

   x = []

   len (x)

for pwd in range(number):

   password = ''

   for c in range (length):
      password += random.choice(chars)

      stuff = "<user name={}{} password={} expire-date={} />".format(usr, x, password, exp)

   print(stuff)

print("</xml-user-manager>")


i expect the output 
<user name=sds[] password=834286 expire-date=999 />
<user name=sds[] password=191481 expire-date=999 />
<user name=sds[] password=191481 expire-date=999 />
to be :
<user name=sds1 password=834286 expire-date=999 />
<user name=sds2 password=191481 expire-date=999 />
<user name=sds3 password=191481 expire-date=999 />

0 个答案:

没有答案