1.用於檢索敏感辭彙 # !/usr/bin/python # -*- coding:utf-8 -*- info = input('請輸入檢索內容:') li = ['蒼老師','東京熱'] for i in li: if i in info: info = info.replace(i,'*** ...
1.用於檢索敏感辭彙
# !/usr/bin/python # -*- coding:utf-8 -*- info = input('請輸入檢索內容:') li = ['蒼老師','東京熱'] for i in li: if i in info: info = info.replace(i,'***') print(info)
2.提示用戶迴圈輸入用戶名,密碼,郵箱,輸入過程中按Q或q退出輸入,輸入字元長度最大為20,輸入結束後按表格列印。
# !/usr/bin/python # -*- coding:utf-8 -*- s = '' while True: print('enter q or Q quit!') print('輸入長度不得超過20個字元,如果超過,只取前20個字元') username = input('請輸入用戶名:')[:20] if username.lower() == 'q': break passwd = input('請輸入密碼:')[:20] if passwd.lower() == 'q': break email = input('請輸入郵箱:')[:20] if email.lower() == 'q': break str = '{}\t{}\t{}\n'.format(username,passwd,email) s += str print(s.expandtabs(20))