【Python Practice】Day 14 Question 51-53
2024-06-26 06:19:16 阅读次数:19
python,编程开发
'''
@Author: your name
@Date: 2020-07-20 22:30:05
@LastEditTime: 2020-07-20 22:59:38
@LastEditors: Please set LastEditors
@Description: In User Settings Edit
@FilePath: \vscode_py\day14.py
'''
# Question 51
def Q51():
return 5/0
# Question 52
# 创建一个异常类
class CustomException(Exception):
def __init__(self,msg):
self.msg = msg
# Question 53
# 分解邮件中的姓名和公司
def Q53():
emails=input().split() # 以空格分开输入中的不同字符串
names=[]
companys=[]
for i in emails:
email=i.split('@') # 分割字符串
names.append(email[0])
company=email[1].split('.')[0]
companys.append(company)
print(",".join(names)) # 以“,”将str迭代器中的每一个str连接起来
print(",".join(companys))
if __name__ == "__main__":
# try:
# Q51()
# except ZeroDivisionError as identifier:
# print("Why on earth you are dividing a number by ZERO!!")
# except:
# print("Other")
# else:
# print("No Error")
# finally:
# print("Always run me")
# num=int(input())
# try :
# if num>10:
# raise CustomException("Input is grater than 10")
# elif num<10:
# raise CustomException("Input is less than 10")
# except CustomException as ce:
# print("The error raised: " + ce.message)
Q53()
版权声明:本文内容来自第三方投稿或授权转载,原文地址:https://blog.51cto.com/u_14355665/6099357,作者:Tech沉思录,版权归原作者所有。本网站转在其作品的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如因作品内容、版权等问题需要同本网站联系,请发邮件至ctyunbbs@chinatelecom.cn沟通。
上一篇:【Win10 应用开发】使用“实时可视化树”工具查看应用界面元素
下一篇:【Python Practice】Day 11 Question 38-43