欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

简易非诚勿扰

程序员文章站 2022-07-14 12:21:09
...
import random
for i in range(0,8):
    nametext = '''冯森宣,周杰,李鑫怡,周厚杰,谢正繁,帅昕宇,肖依然,贾高峰,彭天池'''
    name = nametext.split(",")
    ChoiceName = name[int(random.random() * len(name))]
    print(ChoiceName)
    cityText = '''成都市,资阳市,内江市,德阳市,眉山市,广元市'''
    city = cityText.split(",")
    ChoiceCity = city[int(random.random() * len(city))]
    print(ChoiceCity)
    SexText = ["男", "女"]
    ChoiceSex = SexText[random.randint(0, 1)]
    print(ChoiceSex)
    ChoiceAge = random.randint(18, 50)
    print(ChoiceAge)
    ChoiceIncome = random.randint(20000, 50000)
    print(ChoiceIncome)
    Education = ["小学","初中","高中","大学","研究生","硕士","博士"]
    ChoiceEducation = Education[random.randint(0, 6)]
    print(ChoiceEducation)

运行结果
周杰
德阳市

30
28198
博士
周厚杰
资阳市

38
27122
博士
彭天池
眉山市

36
43131
大学
肖依然
德阳市

25
42051
小学
李鑫怡
德阳市

41
40663
初中
冯森宣
眉山市

25
47831
小学
周厚杰
广元市

44
40316
硕士
帅昕宇
广元市

35
28641
初中

主要练习的是字典和配对