s5_day2作业
# 1:編寫for循環,利用索引遍歷出每一個字符
# msg = 'hello egon 666'
# for i in range(len(msg)):
# print(i,msg[i])
# 2:編寫while循環,利用索引遍歷出每一個字符
# msg = 'hello egon 666'
# i=0
# while i<len(msg):
# print(msg[i])
# i+=1
# 3:
# msg = 'hello alex'
# 中的alex替換成SB
# print(msg.replace('alex','SB'))
# 4:
# msg = '/etc/a.txt|365|get'
# 將該字符的文件名,文件大小,操作方法切割出來
# a=msg.split('|')
# b=a[0].split('/')
# print(b[2],a[1],a[2])
# 5.
# 編寫while循環,要求用戶輸入命令,如果命令為空,則繼續輸入
# while True:
# a=input('請輸入命令:')
# if a.isspace() or not a:
# continue
# break
# 6.
# 編寫while循環,讓用戶輸入用戶名和密碼,如果用戶為空或者數字,則重新輸入
# while True:
# user=input('請輸入用戶 ')
# if user.isspace() or user.isdigit() or not user:
# continue
# else:
# pwd=input('請輸入密碼 ')
# break
# 7.
# 編寫while循環,讓用戶輸入內容,判斷輸入的內容以alex開頭的,則將該字符串加上_SB結尾
# while True:
# a=input("請輸入: ")
# if a.startswith('alex'):
# a+='_SB'
# print(a)
# 8.
# 1.
# 兩層while循環,外層的while循環,讓用戶輸入用戶名、密碼、工作了幾個月、每月的工資(整數),用戶名或密碼為空,或者工作
# 的月數不為整數,或者月工資不為整數,則重新輸入
# 2.
# 認證成功,進入下一層while循環,打印命令提示,有查詢總工資,查詢用戶身份(如果用戶名為alex則打印super
# user,如果用戶名為yuanhao或者wupeiqi
# 則打印normal
# user,其余情況均打印unkown
# user),退出功能
# 3.
# 要求用戶輸入退出,則退出所有循環(使用tag的方式)
#
#
# 運行效果如下:
# user: egon
# password: 123
# work_mons: 12
# salary: 10000
#
# 1
# 查詢總工資
# 2
# 查詢用戶身份
# 3
# 退出登錄
#
# >>: 1
# 總工資是: 120000.0
#
# 1
# 查詢總工資
# 2
# 查詢用戶身份
# 3
# 退出登錄
#
# >>: 2
# unkown
# user
#
# 1
# 查詢總工資
# 2
# 查詢用戶身份
# 3
# 退出登錄
#
# >>: 3 # tag=True
# while tag:
# user = input('user:')
# if user.isspace() and not user:
# continue
# passwd=input('passwd:')
# if passwd.isspace() and not passwd:
# continue
# work_mons=input('work_mons:')
# if work_mons.isdigit():
# work_mons=int(work_mons)
# salary=input('salary:')
# else:
# continue
# if salary.isdigit():
# salary =int(salary)
# while tag:
# print('1 查詢總工資\n2 查詢用戶身份\n3 退出登錄')
# choice=input('請輸入編號')
# if choice=='1':
# print('總工資是: %s'%(work_mons*salary))
# elif choice=='2':
# print(user)
# if user=='alex':
# print('superuser')
# elif user=='wupeiqi'or user=='yuanhao':
# print('normaluser')
# else:
# print('unkown')
# elif choice=='3':
# tag=False
# else:
# continue ?
# while tag:
# user = input('user:')
# if user.isspace() and not user:
# continue
# passwd=input('passwd:')
# if passwd.isspace() and not passwd:
# continue
# work_mons=input('work_mons:')
# if work_mons.isdigit():
# work_mons=int(work_mons)
# salary=input('salary:')
# else:
# continue
# if salary.isdigit():
# salary =int(salary)
# while tag:
# print('1 查詢總工資\n2 查詢用戶身份\n3 退出登錄')
# choice=input('請輸入編號')
# if choice=='1':
# print('總工資是: %s'%(work_mons*salary))
# elif choice=='2':
# print(user)
# if user=='alex':
# print('superuser')
# elif user=='wupeiqi'or user=='yuanhao':
# print('normaluser')
# else:
# print('unkown')
# elif choice=='3':
# tag=False
# else:
# continue ?
?
轉載于:https://www.cnblogs.com/z-x-y/p/6958583.html
總結
- 上一篇: git 项目常用命令
- 下一篇: JAVA-2NIO之Channel