日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > python >内容正文

python

python实现简单的名字管理系统_python列表使用实现名字管理系统

發(fā)布時間:2025/3/12 python 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python实现简单的名字管理系统_python列表使用实现名字管理系统 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

python列表使用實現(xiàn)名字管理系統(tǒng)

來源:中文源碼網(wǎng)????瀏覽: 次????日期:2019年11月5日

【下載文檔:??python列表使用實現(xiàn)名字管理系統(tǒng).txt?】

(友情提示:右鍵點上行txt文檔名->目標(biāo)另存為)

python列表使用實現(xiàn)名字管理系統(tǒng)本文實例為大家分享了python列表使用實現(xiàn)名字管理系統(tǒng)的具體代碼,供大家參考,具體內(nèi)容如下

實現(xiàn)的功能代碼如下:

# 名字管理系統(tǒng) 列表的使用

print("="*50)

print("1:添加名字")

print("2:修改名字")

print("3:查詢名字")

print("4:刪除名字")

print("5:退出")

print("="*50)

names = []

while True:

num = int(input("請輸入要操作的序號:")) # input獲取到的是str,要轉(zhuǎn)換為Int

if num == 1:

name_add = input("請輸入要添加的名字:")

names.append(name_add)

print(names)

elif num == 2:

name_edit1 = input("請輸入要修改的原始名字")

# 法一:

# if name_edit1 in names:

# for i in range(len(names)):

# if name_edit1 == names[i]:

# name_edit2 = input("請輸入要修改為的名字:")

# names[i] = name_edit2

# print("修改成功!")

# else:

# print("查無此人")

# 法二:

find_name = 0 # 默認(rèn)沒找到

for i in range(len(names)):

if name_edit1 == names[i]:

name_edit2 = input("請輸入要修改為的名字:")

names[i] = name_edit2

print("修改成功!")

find_name = 1

if find_name = 0:

print("查無此人")

elif num == 3:

name_select = input("請輸入要查詢的名字:")

if name_select in names:

print("找到了要查找的人")

else:

print("查無此人")

elif num == 4:

name_del = input("請輸入要進(jìn)行刪除的名字:")

if name_del in names:

names.remove(name_del)

print("刪除成功!")

else:

print("查無此人,無法進(jìn)行刪除")

elif num == 5:

break

else:

print("輸入錯誤!")

小編再為大家分享另一段用python中列表實現(xiàn)名字管理系統(tǒng)的代碼:1、打印功能提示

2、獲取用戶輸入

3、根據(jù)用戶的輸入選擇相應(yīng)的功能進(jìn)行實現(xiàn)#打印提示

print("="*50)

print("names_manage_systme")

print("1、add a new name")

print("2、delete a name")

print("3、modify a name")

print("4、search a name")

print("5、quit!")

print("="*50)#存儲用戶姓名

names = []while True:

#獲取用戶輸入

user_input_num = int(input("please input the number you need:"))

#功能實現(xiàn)

if user_input_num == 1: #增加

new_name = input("please input the new name that you need to add:")

names.append(new_name)

print(names)

elif user_input_num == 2: #刪除

del_name = input("please input the new name that you need to delete:")

names.remove(del_name)

print(names)

elif user_input_num == 3: #改

modify_name = input("please input the new name that you need to modify:")

after_modify_name = input("please input the new name :")

length = len(names)

modify_name_index = 0

i = 0

while i < length:

if modify_name == names[i]:

modify_name_index = i

break

i += 1

names[modify_name_index] = after_modify_name

print(names) elif user_input_num == 4: #查找

search_name = input("please input the new name that you need to search:")

length = len(names)

search_name_index = 0

i = 0

while i < length:

if search_name == names[i]:

search_name_index = i

break

i += 1

if i == length:

search_name_index = -1 #沒有找到的話令索引置為-1

print("the index of your search_name is:%d"%search_name_index) elif user_input_num == 5: #退出

print("quit success!")

break

else:

print("input number wrong!\nplease input again")以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持中文源碼網(wǎng)。

親,試試微信掃碼分享本頁!?*^_^*

總結(jié)

以上是生活随笔為你收集整理的python实现简单的名字管理系统_python列表使用实现名字管理系统的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。