python-3.x - 这是一个简单的python装箱单
问题描述
作为一个私人练习,我尝试编写一个小型 python 程序。我经常旅行,总是寻找相同的东西。因此我认为有一个装箱单是有意义的。
我的输入是职业、机动性、小麦和持续时间。我的输出是一个包含项目的列表。
我的文件要大得多,但这是程序的基本部分
packinglist = []
clothes = ["T-Shirt(s)", "Extra Shoes", "Ironed Shirts"]
occupation = []
while occupation != "Business" or occupation !="Private" or occupation
!="Outdoor":
occupation =str(input('Whats the purpose: Business, Private, or Outdoor?\n'))
if occupation == "Business" or occupation =="Private" or occupation =="Outdoor":
print("Okay. Go on!\n")
break
while True:
try:
days = int(input('How many days are you travelling?\n'))
break
except ValueError:
print("Wrong Entry, please type in a posive number!")
我包括了很多条件,例如:
if days >2 and occupation=="Business":
packinglist.append(hardware[2]) #Shaver
packinglist.append(personals[9]) #Watch
packinglist.append(documents[5]) #Card Wallet
packinglist1 = list( dict.fromkeys(packinglist))
print("---clothes---:\n")
for clothes_id in packinglist1:
if clothes_id in clothes:
print(clothes_id)
else:
pass
print("\n")
print("---Summary.---\n")
print("Your Trip is for:", occupation)
print("Wheater condition:", wheater)
print("Sports activites:", sport)
print("Days of duration:", days)
在这里,我添加了包含特定旅程的单独内容的选项
names = []
new_object = ''
while new_object != 'quit':
new_object = input("You want to add something to the list?, or enter 'quit': ")
packinglist1.append(new_object)
有很多更漂亮的编码方式,但我还做不到。因此,如果您愿意,可以给我建议如何改进该程序。
我认为拥有将旅程的“天数”考虑在内的模型会很好。此外,使用例如 Tkinter 的良好可视化看起来非常好。让我们看看会发生什么
解决方案
推荐阅读
- java - Android Studio 布局没有响应
- c++ - 使用 IMFSinkWriter 编码的视频的播放速度根据宽度变化
- java - 切换到新的 Google Maps SDK 时出现迁移错误
- javascript - 考虑到 Windows 10 全局缩放的鼠标位置
- python - 连接两行或多行,而不会在最后一行出现重复
- python - TypeError: 'int' 对象在使用 BeatifulSoup 进行 Webscraping 时不可迭代
- javascript - Node.JS:简单的 GET 请求模块抛出“检测到可能的 EventEmitter 内存泄漏”
- node.js - node.js 背压和排水事件。我遇到了内存泄漏警告
- arraylist - 数字系统之间的变化
- android - Android - FileNotFoundException 打开失败:EACCES(权限被拒绝)