In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces how to use python generator and yield keyword, with certain reference value, interested friends can refer to, I hope you have a lot of gains after reading this article, let Xiaobian take you to understand.
The following code is used to first experience the difference between ordinary list derivations and generators:
# def add():# temp = ["Name", "Student ID", "Class", "Phone"]# dic = {}# lst = []# for item in temp:# inp = input("Please enter {}:".format(item))# if inp == "exit":# print("exit input successfully")# return False# else:# dic[item] = inp# lst.append(dic)# print("Add successfully")# return lst## def show(lst):# print("-"*30)# print("Name\t\tStudent Number\t\tClass\t\tPhone")# print("=" * 30)# for i in range(len(lst)):# for val in lst[i].values():# print(val, "\t", end="")# print()# print("-" * 30)## def search(total_lst):# name = input("Please enter the name of the student you are looking for: ")# flag = False# tmp = []# for i in range(len(total_lst)):# if total_lst[i]["name"] == name:# tmp.append(total_lst[i])# show(tmp)# flag = True# if not flag:# print("Sorry, student not found")## if __name__= '__main__':# total_lst = []# while True:# flag = add()# if flag:# total_lst = total_lst + flag# else:# break# show(total_lst)# search(total_lst)## def show(lst):# print("="*30)# print("{:^25s}".format("Output F1 drivers 'standings"))# print("=" * 30)# print("{:
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.