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

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

Python数据处理相关小例编程

發布時間:2023/12/14 python 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Python数据处理相关小例编程 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

有5名某界大佬xiaoyun、xiaohong、xiaoteng、xiaoyi和xiaoyang,其QQ號分別是88888、5555555、11111、1234321和1212121,用字典將這些數據組織起來。編程實現以下兩個功能:

(1)用戶輸入某一個大佬的姓名后可以輸出其QQ號,如果輸入的姓名不在字典中則返回提示信息并允許再次輸入;

(2)尋找所有有QQ靚號(5位數或小于5位數)的大佬,輸出所有姓名。

其中Python 2中提示輸入和輸出結果的兩句提示語請使用如下形式:

name = raw_input("Please input the name:")

print ?"Who has the nice QQ number?"

其中Python 3中提示輸入和輸出結果的兩句提示語請使用如下形式:

name = input("Please input the name:")

print("Who has the nice QQ number?")

>>> adict = {'xiaoyun':88888, 'xiaohong':5555555, 'xiaoteng':11111, 'xiaoyi':1234321, 'xiaoyang':1212121} >>> def qq():name = input('Please input the name:')if name in adict.keys():print(adict[name])else:print( 'The name does not exist.')a = input('Try again:y or n?')if a == 'y':qq()else:return 'Bey!'>>> qq() Please input the name:q The name does not exist. Try again:y or n?y Please input the name:xiaoyun 88888 >>> qq() Please input the name:xiaoyun 88888 >>> qq() Please input the name:q The name does not exist. Try again:y or n?n 'Bey!' >>> def nm(): <span style="white-space:pre"> </span>print('Who has the nice QQ number?') <span style="white-space:pre"> </span>for i in adict.keys(): #!!! <span style="white-space:pre"> </span>if len(str(adict[i])) <= 5: #整數沒有長度,要轉化成字符串 <span style="white-space:pre"> </span>print(i)<span style="white-space:pre"> </span> >>> nm() Who has the nice QQ number? xiaoyun xiaoteng

總結

以上是生活随笔為你收集整理的Python数据处理相关小例编程的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。