摘要:
def calculate_and_print(num, calculator, formatter): result = calculator(num) formatter(num, result)def print_with_vertical_bar(num, result): print(f"
阅读全文
posted @ 2025-10-31 21:33
偷懒的阿贤
阅读(3)
推荐(0)
摘要:
#导入测试内置模块import unittest#导入要测试的api,Student为类名from _oop import Studentfrom _oop import SmallStudent#需要继承unittest.TestCase,def函数必须用test_开头class MyTestCa
阅读全文
posted @ 2025-10-31 21:02
偷懒的阿贤
阅读(4)
推荐(0)
摘要:
#导入测试内置模块import unittest#导入要测试的apifrom _try_except import condition#需要继承unittest.TestCase,def函数必须用test_开头class MyTestCase(unittest.TestCase): def test
阅读全文
posted @ 2025-10-31 20:36
偷懒的阿贤
阅读(5)
推荐(0)
摘要:
try: user_weight = float(input("请输入您的体重(单位:kg):")) user_height = float(input("请输入您的身高(单位:m):")) user_BMI = user_weight / (user_height ** 2)except Valu
阅读全文
posted @ 2025-10-31 20:20
偷懒的阿贤
阅读(6)
推荐(0)
摘要:
#在一个新的名字为“poem.txt”的文件里,写入以下内容:#我欲乘风归去#又恐琼楼玉宇with open("./poem.txt", "w", encoding="utf-8") as f: f.write("我欲乘风归去,\n又恐琼楼玉宇.\n")#任务2:在上面的poem.txt中文件结尾处
阅读全文
posted @ 2025-10-31 17:58
偷懒的阿贤
阅读(2)
推荐(0)
摘要:
#方法一:读取文件f = open("./_math.py", "r", encoding="utf-8")content = f.readlines()for line in content: print(line)f.close()#方法二:读取文件,不用close()with open("./
阅读全文
posted @ 2025-10-31 17:57
偷懒的阿贤
阅读(3)
推荐(0)
posted @ 2025-10-31 17:44
偷懒的阿贤
阅读(3)
推荐(0)
摘要:
class Employee: def __init__(self, name, id): self.name = name self.id = id def print_info(self): print(f"员工名字:{self.name},工号:{self.id}")class FullTim
阅读全文
posted @ 2025-10-31 17:25
偷懒的阿贤
阅读(3)
推荐(0)
摘要:
class Student: def __init__(self, name, student_id): self.name = name self.student_id = student_id self.grades = {"语文": 0, "数学":0, "英语": 0} def set_gr
阅读全文
posted @ 2025-10-31 16:50
偷懒的阿贤
阅读(5)
推荐(0)