|
|
|
|
@ -1,29 +1,32 @@
|
|
|
|
|
import time
|
|
|
|
|
from datetime import datetime
|
|
|
|
|
|
|
|
|
|
def display_live_time():
|
|
|
|
|
"""
|
|
|
|
|
实时显示当前时间,每秒更新一次。
|
|
|
|
|
"""
|
|
|
|
|
try:
|
|
|
|
|
while True:
|
|
|
|
|
# 1. 获取当前时间
|
|
|
|
|
now = datetime.now()
|
|
|
|
|
|
|
|
|
|
# 2. 格式化时间为字符串 (年-月-日 时:分:秒)
|
|
|
|
|
current_time_str = now.strftime("%Y-%m-%d %H:%M:%S")
|
|
|
|
|
|
|
|
|
|
# 3. 打印时间。end='\r' 表示不换行,而是将光标移回行首,实现覆盖更新。
|
|
|
|
|
# flush=True 确保立即显示在终端。
|
|
|
|
|
print(f"当前时间: {current_time_str}", end="\r", flush=True)
|
|
|
|
|
|
|
|
|
|
# 4. 暂停1秒
|
|
|
|
|
time.sleep(1)
|
|
|
|
|
|
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
|
# 当用户按下 Ctrl+C 时,捕获 KeyboardInterrupt 异常,
|
|
|
|
|
# 打印一个换行和提示信息,然后优雅地退出程序。
|
|
|
|
|
print("\n程序已退出。")
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
display_live_time()
|
|
|
|
|
ard=[]
|
|
|
|
|
for i in ls:
|
|
|
|
|
card.append((i,"红桃"))
|
|
|
|
|
for i in ls:
|
|
|
|
|
card.append((i,"黑桃"))
|
|
|
|
|
for i in ls:
|
|
|
|
|
card.append((i,"梅花"))
|
|
|
|
|
for i in ls:
|
|
|
|
|
card.append((i,"方块"))
|
|
|
|
|
m = int(input("请输入A抽取的序号(1-52),输入0结束:"))
|
|
|
|
|
a = int(input("请输入B抽取的序号(1-52),输入0结束:"))
|
|
|
|
|
while m!=0 and a!=0:
|
|
|
|
|
while a == m:
|
|
|
|
|
a = int(input("重复!请重新输入B抽取的序号(1-52),输入0结束:"))
|
|
|
|
|
random.shuffle(card)
|
|
|
|
|
if 1<=m<=52 and 1<=a<=52:
|
|
|
|
|
print("A的牌:",card[m-1][0],end="----")
|
|
|
|
|
print("B的牌:",card[a-1][0])
|
|
|
|
|
if ls.index(card[m-1][0])<ls.index(card[a-1][0]):
|
|
|
|
|
print("B赢了!")
|
|
|
|
|
elif ls.index(card[m-1][0])>ls.index(card[a-1][0]):
|
|
|
|
|
print("A赢了!")
|
|
|
|
|
elif ls.index(card[m-1][0])==ls.index(card[a-1][0]):
|
|
|
|
|
print("打平!")
|
|
|
|
|
m = int(input("请输入A抽取的序号(1-52),输入0退出:"))
|
|
|
|
|
a = int(input("请输入B抽取的序号(1-52),输入0结束:"))
|
|
|
|
|
elif 1<=m<=52 and (a<1 or a>52):
|
|
|
|
|
a = int(input("不存在!请重新输入B抽取的序号(1-52),输入0退出:"))
|
|
|
|
|
elif 1<=a<=52 and (m<1 or m>52):
|
|
|
|
|
m = int(input("不存在!请重新输入A抽取的序号(1-52),输入0退出:"))
|
|
|
|
|
print("结束!谢谢您的使用!")
|
|
|
|
|
print("2315304160 软工一班 臧博文")
|