程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

[Master Wus Python bakery] day 1

編輯:Python

Preface : Master Wu, who can only stay at home on the national day, is very boring , Decided to open a Python The bakery passed the time . Every day after that , Master Wu will use a piece of code to simply realize the function of selling bread , And solve the problems exposed the day before .

Master Wu's Python The bakery opened , Today is the first day , First, simply implement the function of selling bread .

""" There is one python Baker , The customer waits for the Baker to finish the bread and take away the bread ."""
import time
def producer():
""" Making bread ."""
time.sleep(1)
return 1
def consumer():
""" consumer , You have to say something to buy bread ."""
print("I am so happy.")
def run():
total = 0
while True:
num = producer()
if num:
consumer()
total += num
if total >= 10:
# Shifu did it 10 A loaf of bread is coming off work .
print('Finished.')
break
if __name__ == "__main__":
run()

The first day of opening was fairly smooth , Some customers complain that the waiting time is too long , How can master Wu quickly solve this problem ?


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved