Austin_zhai
Austin_zhai
全部文章
分类
题解(18)
归档
标签
去牛客网
登录
/
注册
Austin_zhai的博客
全部文章
(共54篇)
题解 | #提取数字电话#
导入re包 import re 定义接收数据的变量 tel = input() 进行正则匹配并打印结果 res = re.sub(r'[^0-9]+', '', tel) print(res)
Python3
2022-09-28
0
338
题解 | #正则查找网址#
导入re包 import re 定义接收数据与样本的变量 url = input() sample = 'https://www' 进行结果的匹配与输出 res = re.match(sample, url) print(res.span())
Python3
2022-09-28
0
402
题解 | #重载运算#
定义接收数据的变量,这边可以用map函数进行变量与数据的匹配 x1, y1 = list(map(int, input().split(" "))) x2, y2 = list(map(int, input().split(" "))) 定义Coordinat...
Python3
2022-09-27
4
470
题解 | #修改属性2#
定义接收数据的变量 name = input() salary = int(input()) age = int(input()) 定义Employee类 class Employee: def __init__(self, name, salary): self.name...
Python3
2022-09-27
19
732
题解 | #修改属性1#
定义接收数据的变量 name = input() salary = int(input()) age = int(input()) 定义Employee类与相关函数 class Employee: def __init__(self, name, salary): self....
Python3
2022-09-27
6
449
题解 | #班级管理#
定义接收数据的变量 name = input() number = input() score = int(input()) grade = input().split(" ") 定义Student类的业务逻辑 class Student: def __init__(se...
Python3
2022-09-27
0
377
题解 | #球的表面积#
导入math包下的pi函数 from math import pi 定义表面积计算函数 def area(radius): v = 4 * pi * radius**2 return v 定义相关入参与输出循环计算结果 list_a = [1, 2, 4, 9, 10, 13] f...
Python3
2022-09-27
15
543
题解 | #兔子的数量#
定义接收数量的变量 n = int(input()) 定义兔子增长的函数,根据题目的要求设定即可 def rabbit(n): if n == 3: return 5 elif n == 2: return 3 elif n == 1: ...
Python3
2022-09-27
0
359
题解 | #函数求差#
定义接收两个数字的变量 x = int(input()) y = int(input()) 定义cal函数 def cal(x, y): return x - y 调用cal函数,如果定义函数不用return而是print函数的话此处可以直接调用,不用打印输出 print(cal(x, y)...
Python3
2022-09-27
0
398
题解 | #创建集合#
定义接收数据与集合的变量 name = input().split(" ") collection = set() 使用for循环遍历分割空格后的字符串,利用set的特性就行去重 for i in name: collection.add(i) 使用sorted函数进行排...
Python3
2022-09-27
6
559
首页
上一页
1
2
3
4
5
6
下一页
末页