方法在字符串指定范围中查找所有符合正则表达式的字符串并以列表.PPT

方法在字符串指定范围中查找所有符合正则表达式的字符串并以列表.PPT

4.1.5 字符串应用案例精选 def getSex(): return random.choice((男, 女)) def getAge(): return str(random.randint(18,100)) * 4.1.5 字符串应用案例精选 def main(filename): with codecs.open(filename, w, utf-8) as fp: fp.write(Name,Sex,Age,TelNO,Address,Email\n) #随机生成200个人的信息 for i in range(200): name = getNameOrAddress(1) sex = getSex() age = getAge() tel = getTelNo() address = getNameOrAddress(0) email = getEmail() line = ,.join([name, sex, age, tel, address, email]) + \n fp.write(line)

文档评论(0)

1亿VIP精品文档

相关文档