![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python小程序
yuan04040404
希望与大家一起学习一起进步!
展开
-
用python写99乘法表保存在Excel里
用python写99乘法表保存在Excel原创 2022-05-16 20:52:31 · 425 阅读 · 0 评论 -
用python创建文本用户输入函数,读取、复制信息到指定文本函数(并且有异常处理)
题目如下代码如下def w(): try: f=open("gushi.txt","w") f.write(input("请输入古诗:")) print("输入到gushi文件成功!") f.close() except Exception as result: print("有错误!!!")def r(): try: w() f=open("gushi.txt") c=open("copy.txt","w") .原创 2022-04-23 09:36:35 · 208 阅读 · 0 评论 -
用python完成商品的名称、价格表显示,用户选择商品并统计结果
这个是要完成的内容代码如下print("-----------商品列表-------------")products=[["iphone","6888"],["MacPro","14800"],["MI6","2499"],["Coffee","31"],["Book","60"],["Nike","699"]]i=0j=0N=2k=0buy=[]while i<6: print("%-5d%-9s%s"%(i,products[i][0],products[i].原创 2022-04-23 09:33:41 · 7003 阅读 · 0 评论 -
用python解决8人随机分配3房间问题
import randomteather=["小明","小红","小华","小花","小白","小度","小菜","小天"]room=[[],[],[]]i=0for teacher_name in teather: idex=random.randint(0,2) room[idex].append(teacher_name)print("第一房间睡的是%s\n第二个房间睡的是%s\n第三个房间谁的是%s\n"%(room[0],room[1],room[2]))这程序主.原创 2022-04-23 09:30:08 · 2762 阅读 · 0 评论 -
用python简单的写一个剪刀石头布的小游戏
N=10win=0gg=0same=0no=0for x in range(0,N,1): print("-"*20) print("石头剪刀布小游戏\n 0代表石头,1代表剪刀,2代表布") import random date =["石头", "剪刀", "布"] b=random.randint(0,2) a=int(input("请输入0或1或2: ")) if a!=0 and a!=1 and a!=2: pri.原创 2022-04-23 09:26:40 · 2950 阅读 · 0 评论