Allen_Wu233 2021-05-03 19:30 采纳率: 50%
浏览 43
已结题

【萌新求助】关于根据用户的输入来使用已有的字典

from random import randint
from time import sleep

import 卡池 

stone = 100
result = []
dictionary = {}

print("欢迎来到Allen抽卡模拟器!")
tip = input("请选择卡池(test/常驻/):")
try:
	dictionary = f'{tip}'
	print(dictionary)
except:
	print("Error!")

def one():
	b = randint(1,1000)
	if b>=0 and b<=10:
		a = six_stars[randint(0,int(len(six_stars))-1)]
		result.append(a)
		print(a)
	elif b>=11 and b<=100:
		a = five_stars[randint(0,int(len(five_stars))-1)]
		result.append(a)
		print(a)
	elif b>=101 and b<=400:
		a = four_stars[randint(0,int(len(four_stars))-1)]
		result.append(a)
		print(a)	
	else:
		a = three_stars[randint(0,int(len(three_stars))-1)]
		result.append(a)
		print(a)

def ten():
    for i in range(10):
        one()

while stone > 0:
	a = input(f"\n石头数:{str(stone)}\n输入1单抽,输入2十连:\n(输入'q'以退出)")
	if a == '1':
		stone -= 1
		one()
	if a == '2':
		if stone >= 10:
			stone -= 10
			ten()
		else:
			print('石头不足!')

	if a == 'q':
		break
	while stone == 0:
		tip = input('\n石头不足,是否氪金?(y/n)')
		if tip == 'y':
			stone += 100
			print('氪金成功!')
		if tip == 'n':
			break

print('\n抽卡数:' + str(len(result)))

print("六星:",end="")
for i in six_stars:
	print(f"{i}:{str(result.count(i))}",end=" ")
print(f"\n")

print("五星:",end="")
for i in five_stars:
	print(f"{i}:{str(result.count(i))}",end=" ")
print(f"\n")

print("四星:",end="")
for i in four_stars:
	print(f"{i}:{str(result.count(i))}",end=" ")
print(f"\n")

print("三星:",end="")
for i in three_stars:
	print(f"{i}:{str(result.count(i))}",end=" ")
print(f"\n")

print('\n已退出模拟器!')

如图为一个简单的模拟抽卡程序,我的目的是让用户能自主选择卡池。

已经尝试了input(),发现只能返回一个字符串。

在线等大佬帮助!wei'x

  • 写回答

4条回答 默认 最新

  • 关注

    import 卡池 是什么?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 7月30日

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料