main.py
from data import mock_data
from cmd.show_names import show_list
import os
def print_useage():
print("\t\t---------欢迎使用Facebook系统,具体命令如下:-------")
print("list: 显示名单")
print("886: 再见")
print("张三:查询张三的信息")
names, records = mock_data()
# print(names)
# print(records)
# for record in records:
# print(f"{record[0][1]} {record[1][0]} {record[2][1]} {record[-1]}")
while True:
print_useage()
cmd = input("请输入命令:")
if cmd == "list":
# print("显示名单")
show_list(names)
elif cmd == "886":
print("再见")
break
else:
print("张三....")
# os.system("cls")
# input("回车继续.....")
data.py
import random
xingstr = "王,李,张,刘,陈,杨,黄,赵,周,吴,徐,孙,马,胡,朱,郭,何,罗,高,林"
mingstr = "浚屹,文西,玮泓,朗威,少华,杰奕,棋通,昭海,炳颜,晟驰,玮鹤,昱旷,洛流,涛鹤,畅忆,玖寅,天旭,羽濬,译文,任浚,智琛,杰通,石棕,瀚天"
add_score_things = "点赞,投币,赞美,帮助,送礼物"
reduce_score_things = "骂,打,白嫖,欺骗"
names = []
records = []
def mock_names():
xing_str = xingstr.split(",")
ming_str = mingstr.split(",")
for x in range(20):
xing = random.choice(xing_str)
ming = random.choice(ming_str)
names.append((x+1, xing + ming))
def mock_records():
good_things = add_score_things.split(",")
bad_things = reduce_score_things.split(",")
things = good_things + bad_things
for y in range(20):
n1 = random.choice(names)
n2 = random.choice(names)
thing = random.choice(things)
if (things.index(thing) >= len(good_things)): # thing 在 things 列表中 下标的 位置 ,为什么 是 >=len(?)
scores = -1
else:
scores = 1
records.append((n1,thing,n2,scores))
def mock_data():
mock_names()
mock_records()
return names,records
cmd/show_names.py
def show_list(names):
for name in names:
print(f"{name[0]},{name[1]}")