当前位置: 首页 > news >正文

python 学习基本语法整理

基本语法

参考两个视频

  • 非常快速了解python基础知识bilibili
  • 比较全的课程 知乎知学堂

hello world

## 1. Hello, World!
print("Hello, World!")
#
##这是Python中最简单的示例代码,用于输出"Hello, World!"到屏幕上。它是学习任何编程语言的第一步。

print

print ("Dad!!!")
print ("he said 'hello'" + " my" + " name")
print ('Let\'s go')
print("我是第一行\n我是第二行\n")
print("""离离原上草⑵,一岁一枯荣⑶。
野火烧不尽⑷,春风吹又生。
远芳侵古道⑸,晴翠接荒城⑹。
又送王孙去⑺,萋萋满别情⑻。""")
#print不换行的写法
print('hello world',end='')
print('  goodbye, world')

变量

命名风格:

  • 下划线命名法(Snack case) user_name,user_age
  • 驼峰命名法 UserName,UserAge
  • 变量命名的基本规则
    1. 变量名必须以字母(大写或小写)或下划线(_)开头,不能以数字开头。
    2. 变量名只能包含字母、数字和下划线。
    3. 变量名是大小写敏感的,例如,name和Name会被视为两个不同的变量。
    4. 变量名不能使用Python的关键字,如True、False、None等。
    5. 见名知意
my_name=("       徐炜华         ")
print("hello "+my_name)
import math
result = math.log2(8)
print (result)

数学运算

基本运算

python运算符

# 整除
print(123//5)
# 求余数(模)
print(123%5)

采用math库

import math
result = math.log2(8)
print (result)#求二元一次方程的两个根
a=-1
b=-2
c=3
result1=(-b+math.sqrt(b**2-4*a*c))/(2*a)
result2=(-b-math.sqrt(b**2-4*a*c))/(2*a)

注释

  • control +/ 使行前产生 #字符,代表注释
  • 三引号"“” “”"
    接上段代码
#不能用+连接字符串和其他类型的变量
# print("result1="+result1 )
# print ("result2="+result2 )
"""
print("result1="+result1 )
print ("result2="+result2 )
"""
print("result1=", result1 )
print ("result2=", result2 )
  • python script 模板设置
    在这里插入图片描述
    效果如下
"""
test -
Author:Administrator
Date:2025/3/23
"""

数据类型

  • 字符串
#打印第四个字符
print("hello"[3])
print("length",len("hello"))
#转义符\
print ('Let\'s go')
  • int
    1. 0o110 八进制
    2. 0x110 十六进制
    3. 0b110 二进制
      bin(47) 十进制转二进制
      oct(47) 十进制转八进制
      hex(47) 十进制转十六进制
# bin(47)
# 十进制转二进制
print(bin(47))
# oct(47)
# 十进制转八进制
print(oct(47))
# hex(47)
# 十进制转十六进制
print(hex(47))
0b101111
0o57
0x2f
  • float 1.23 / 1.23e-5
    浮点数的坑
    浮点运算不可信
C:\Users\Administrator>python
Python 3.12.2 (tags/v3.12.2:6abddd9, Feb  6 2024, 21:26:36) [MSC v.1937 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> 0.1+0.2
0.30000000000000004
>>> 0.1+0.2+0.3
0.6000000000000001
>>> 0.3+0.2+0.1
0.6
>>>
  • bool类型
b1=True
b2=False
  • complex复数型(2+3j)
  • NoneType
n=None
  • 返回对象类型
print(type(b1))
print(type(result1))
  • 不同类型不能混用
# print("result1="+result1 )
# print ("result2="+result2 )
print("result1="+str(result1) )
print ("result2="+str(result2) )

input

  • 交互模式
    在这里插入图片描述
C:\Users\Administrator>python
Python 3.12.2 (tags/v3.12.2:6abddd9, Feb  6 2024, 21:26:36) [MSC v.1937 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> 2+3
5
>>> 5*8
40
>>> name="xuweihua"
>>> print(name)
xuweihua
>>> import this
The Zen of Python, by Tim PetersBeautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
>>> import antigravity
>>> quit()

在这里插入图片描述

  • 直接运行python 文件
C:\Users\Administrator>python D:\hello.py
hello world!
  • 更好用的交互模式软件(ipython)
C:\Users\Administrator>pip config set global.index-url http://pypi.doubanio.com/simple
Writing to C:\Users\Administrator\AppData\Roaming\pip\pip.iniC:\Users\Administrator>pip install ipython
  • 命令模式
#BMI=体重/(身高**2)
user_weight=float(input("请输入你的体重(单位:Kg):"))
user_height=float(input("请输入你的身高(单位:m):"))
user_BMI=user_weight/(user_height**2)
print ("user_BMI= ",user_BMI)
print ("你的BMI= "+ str(user_BMI))

条件 if else

  • 单个条件
mood_index=int(input("对象现在的心情指数是(输入数字):"))
if mood_index>=60:print("恭喜,今晚应该可以打游戏,去吧皮卡丘")
else: # mode_index < 60print("为了自个儿的小命,还是别打了")
  • 多条件
#BMI=体重/(身高**2)
user_weight=float(input("请输入你的体重(单位:Kg):"))
user_height=float(input("请输入你的身高(单位:m):"))
user_BMI=user_weight/(user_height**2)
print ("user_BMI= ",user_BMI)
print ("你的BMI= "+ str(user_BMI))#偏瘦 user_BMI<=18.5
#正常 18.5<user_BMI<=25
#偏胖 30>=user_BMI>25
#肥胖 user_BMI >30
if user_BMI<=18.5 :print("你偏瘦")
elif 18.5<user_BMI<=25 :print("你身材正常")
elif 30>=user_BMI>25:print("你偏胖")
else:print("你肥胖了")`

List

shopping_list=[]
shopping_list.append("键盘")
shopping_list.append("键冒")
print(shopping_list)
print(shopping_list[1])
shopping_list.remove("键盘")
print(shopping_list)
shopping_list.append("音响")
print(shopping_list)
shopping_list[0]="手机"
print(shopping_list)
print(shopping_list.pop())
print(shopping_list)
for i in range(len(shopping_list)): #可以在循环体中改值print(shopping_list[i])
#    shopping_list[i]="abc"
for x in shopping_list:#只能读出值,无法修改值print(x)
for i,x in enumerate(shopping_list):#可以读出索引和值,就此可以通过索引修改值print(i,x)price_list=[100,150,200,250]
max_p=max(price_list)
min_p=min(price_list)
sort_p=sorted(price_list)
print(max_p,"\n",min_p,"\n",sort_p)
#计算骰子摇出点数的次数
import random#fs = [0, 0, 0, 0, 0, 0]
fs=[0]*6
for _ in range(60000):face = random.randrange(1, 7)fs[face - 1] += 1
for i,value in enumerate(fs):print(f"{i+1}点摇出了{value}次")

字典

my_dict={"yyds":"永远的神,形容某人或某事物非常优秀",
"PUA":"情感操控,揭露不健康恋爱关系",
"emo":"情绪低落、丧",
"破防":"情绪被触动到无法保持理性",
"摆烂":"放弃努力,消极对待",
"躺平":"主动放弃内卷,选择佛系生活",
"绝绝子":"非常绝妙的夸张称赞",
"拿捏":"对某事掌控自如",
"社死":"社交场合尴尬到想“当场去世”",
"内卷":"过度竞争导致资源浪费",
"打工人":"自嘲上班族身份",
"凡尔赛":"表面谦虚实则炫耀",
"孤勇者":"勇敢面对困境的人",
"双厨狂喜":"同时喜欢两位角色/演员的满足感",
"反内核":"看似打破常规实则符合套路",
"小作文":"社交平台长文吐槽或澄清",
"社恐":"社交恐惧症自嘲",
"工具人":"被动帮助他人完成任务",
"爷青回":"经典事物回归的感叹",
"无效努力":"付出未获回报",
"整活":"制造有趣或恶搞内容",
"嗑CP":"热衷关注特定角色关系",
"加个好友不打排位":"调侃表面功夫",
"三连":"点赞、评论、转发的全方位支持",
"别emo了,来点正能量":"劝慰振作",
"逆天改命":"通过努力改变命运",
"社会你哥,人狠话不多":"形容气场强大的人",
"天花板":"某领域顶尖存在",
"xp":"指代个人偏好或特质",
"zqsg":"表达情绪真实程度",
"666":"表示赞同或崇拜",
"鸭梨山大":"形容压力巨大",
"咕值":"表达沮丧或不满",
"skr":"表示兴奋或激动",
"佛系":"随遇而安的生活态度",
"牛批":"形容事物或能力出色",
"doge":"形容可爱或有趣",
"low":"形容低调或消极",
"996":"争议性工作制度(早9晚9,每周6天)",
"班味":"打工人疲惫气质,形容职场内卷下的倦怠感",
"剥罗森":"河南方言梗,相亲礼仪笑点",
"人脸痞老板":"伏地魔与痞老板的魔性组合",
"咖啡不断加加加加到厌倦":"电音翻唱引发模仿热潮",
"建议岳云鹏别上春晚":"观众调侃成爆梗",
"尊嘟假嘟":"谐音“真的假的”,表达怀疑",
"纸性恋":"偏好虚拟角色的情感取向",
"发疯文学":"无厘头情绪宣泄方式",
"痛文化":"二次元装饰文化",
"硬控":"形容强烈吸引力",
"水灵灵地":"形容生动鲜活的状态,常用于自嘲或调侃",
"偷感(很重)":"形容做事拘谨、小心翼翼的状态,体现社恐心理",
"city不city":"外国博主魔性语调引发的洗脑热梗,用于调侃城市体验",
"古希腊掌管××的神":"用于调侃某领域顶尖人物或事物",
"红温":"形容情绪激动面部发红的状态,比“脸红”更委婉",
"搞抽象":"用荒诞戏谑方式表达情绪或信息",
"那咋了":"反问句式表达坦然面对困难的态度",
"新质生产力":"2024年十大网络用语,指科技创新驱动的生产力",
"偏偏你最争气":"《黑神话:悟空》爆火后,网友用此表达对国产游戏的赞美",
"浓人淡人":"形容情绪浓烈或淡泊的人生态度",
"主理人":"原指潮流品牌领导者,现多用于调侃直播带货中的套路",
"北京到底有谁在啊":"电视剧台词被官媒接梗,成为城市宣传热梗",
"先秦淑女步":"《庆余年》二皇子魔性步伐引发的模仿热潮",
"请苍天鉴忠奸":"影视剧台词被网友二创为表情包,用于自证清白",
"人生易如如掌":"日剧台词中“人生ちょるかった”被翻译成正能量金句",
"新造的人":"电影《周处除三害》中反差感强烈的角色梗",
"牛马":"自嘲为生活辛苦奔波的打工人",
"MBTI中的J/P人":"刻板印象分类,J人重计划,P人爱灵活",
"岁正是该de nian的年纪":"奥运冠军潘展乐夺冠后的幽默告状金句",
"毛环":"网络热梗,谐音“马化腾”"}
my_dict["精装朋友圈"]="形容朋友圈过度修饰的虚假社交"
print(str(len(my_dict)))
print("996的含义是:",my_dict["996"])
# query= input("请输入您想要查的流行语")
# if query in my_dict:
#     print("您查询的"+query+"含义是")
#     print(my_dict[query]){
# else:
#     print("未收录此词")
#     print("总共收录了",len(my_dict),"条流行语")
for my_key,my_value in my_dict.items() :print (my_key+" ☞ "+my_value)

for-in 循环和range

fruits = ["apple", "banana", "cherry"]
for fruit in fruits:print(f"I like {fruit}s")print("I like ",fruit,"s")print("I like "+fruit+"s")
for i in range(10) : #0-->9print(i,"first")
for i in range(3,10) :print(i,"second")
for i in range(10,20,2) :#10-->18print(i,"third")

可以用break提前结束循环

# 求两个整数的最大公约数
x = int(input("x="))
y = int(input("y="))
for i in range(x, 0, -1):if x % i == 0 and y % i == 0:print(f"{x}{y}的最大公约数为:{i}")break  # 提前结束循环

while

total =0.0
count =0
input_str=input("please input your number,until q/Q: ")
while input_str != "q" and input_str != "Q":num=float(input_str)total+= numcount+=1input_str=input("please input your number,until q/Q: ")
if count==0 :result=0
else :result=total/count
print("平均值为:"+str(result))

格式问题

a1 = float(input("a1= "))
b2 = float(input("b2= "))
print("%f + %f = %f" % (a1,b2,a1+b2) ) #可以用%.1f表示保留小数点后1位
print("%f %% %f = %f" % (a1,b2,a1%b2) ) #%求余数,用%%转义
a1= 1.2
b2= 2.4
1.200000 + 2.400000 = 3.600000
1.200000 % 2.400000 = 1.200000
a1 = int(input("a1= "))
b2 = int(input("b2= "))
print("%d + %d = %d" % (a1,b2,a1+b2) )
print("%d %% %d = %d" % (a1,b2,a1%b2) ) #%求余数,用%%转义
a1= 1
b2= 3
1 + 3 = 4
1 % 3 = 1

用print(f" ") 这里 f 是格式format的意思

a1 = float(input("a1= "))
b2 = float(input("b2= "))
print(f"{a1}+{b2}={a1+b2}")
print(f"{a1:.1f}+{b2:.2f}={(a1+b2):.3f}")
a1= 1.2
b2= 2.4
1.2+2.4=3.5999999999999996
1.2+2.40=3.600
contacts = ["老李","老张","老王"]
year="虎"
# for name in contacts:
#     message_content="""
#     绿回
#     金"""+year+"""贺岁
#     给""" +name+"""拜年
#     """
#     print (message_content)
# for name in contacts:
#     message_content="""
#     绿回
#     金{0}贺岁
#     给{1}拜年
#     """.format(year,name)
#     print (message_content)
# for name in contacts:
#     message_content="""
#     绿回
#     金{cyear}贺岁
#     给{cname}拜年
#     """.format(cyear=year,cname=name)
#     print (message_content)
# for name in contacts:
#     message_content=f"""
#     绿回
#     金{year}贺岁
#     给{name}拜年
#     """
#     print (message_content)
# for name in contacts:
#     print (f"""
#     绿回
#     金{year}贺岁
#     给{name}拜年
#     """)# gpa_dict={"xiaom":3.251,"hua":3.869}
# for name,gpa in gpa_dict.items():
#     print("hello {0},your mark is:{1:.1f}".format(name,gpa))
gpa_dict={"xiaom":3.251,"hua":3.869}
for name,gpa in gpa_dict.items():print(f"hello {name},your mark is:{gpa:.1f}")

For_in,while, if的综合使用(穷举法)

# 五人分鱼问题:A、B、C、D、E 五人在某天夜里合伙去捕鱼,到第二天凌晨时都疲惫不堪,于是各自找地方睡觉。
# 日上三杆,A 第一个醒来,他将鱼分为五份,把多余的一条鱼扔掉,拿走自己的一份。
# B 第二个醒来,也将鱼分为五份,把多余的一条鱼扔掉拿走自己的一份。
# C、D、E依次醒来,也按同样的方法拿鱼。
# 问他们至少捕了多少条鱼?
fish = 6
while True:is_enough = Truetotal = fishfor _ in range(5):if (total - 1) % 5 == 0:total = (total - 1) // 5 * 4else:is_enough = Falsebreakif is_enough:print(fish)breakfish += 5

function

def calculate_section(central_angle,radius):sector_area=central_angle/360*3.14*radius**2print(f"面积={sector_area:.3f}")calculate_section(30,10)
# def calculate_section(central_angle,radius):
#     sector_area=central_angle/360*3.14*radius**2
#     print(f"面积={sector_area:.3f}")
#     return sector_area
#
# f = calculate_section(30,10)
# print(f"the result= {f:.5f}")#BMI=体重/(身高**2)
def BMI_hint(user_weight,User_height):user_BMI = user_weight / ((user_height/100) ** 2)if user_BMI <= 18.5:category="偏瘦"elif 18.5 < user_BMI <= 25:category="正常"elif 30 >= user_BMI > 25:category="偏胖"else:category="肥胖"print(f"你的体重为{category}")return user_BMI
while input("please input any key except q") !='q':user_weight=float(input("请输入你的体重(单位:Kg):"))user_height=float(input("请输入你的身高(单位:cm):"))result=BMI_hint(user_weight,user_height)print(f"你的BMI值为{result:.3f}")

类定义

class CuteCat:def __init__(self,cat_name,cat_age,cat_color):self.name=cat_nameself.age=cat_ageself.color=cat_colordef speak(self):print("喵"*self.age)
cat1=CuteCat("Jojo",2,"Grey")
print(cat1.name)
cat1.speak()class Student :def __init__(self,name,student_id):self.name=nameself.student_id=student_idself.grades={"Chinese":0,"Maths":0,"English":0}def setgrade(self):course=input(f"please input {self.name} 's course you want to set:")if course in self.grades:grade=input("please input the grade:")self.grades[course]=gradedef getgrade(self):print(self.name,"的三科成绩为:",self.grades)print(f"{self.name}(学号{self.student_id})的三科成绩为:{self.grades}")for course in self.grades:print(f"{course}:{self.grades[course]}分")
chen=Student("XiaoChen","1001")
li=Student("XiaoLi","1002")
# print(chen.name,chen.grades)
# print(li.name,li.grades)
chen.setgrade()
chen.getgrade()
li.setgrade()
li.getgrade()

继承

class Mammal:def __init__(self,name,sex):self.name=nameself.sex=sexself.num_eyes=2def breathe(self):print(self.name+" is breathing")def poop(self):prin他(self.name+" is pooping")
class Human(Mammal):def read(self):print(self.name+" is reading")
class Cat(Mammal):def scratch_sofa(self):print(self.name+" is scratching sofa")def poop(self):print(self.name+" is pooping in sand")cat1=Cat("Kitty","girl")
human1=Human("xiao zhang","boy")
cat1.breathe()
human1.read()
cat1.poop()
class Mammal:def __init__(self,name,sex):self.name=nameself.sex=sexself.num_eyes=2def breathe(self):print(self.name+" is breathing")def poop(self):prin他(self.name+" is pooping")
class Human(Mammal):def __init__(self, name, sex):super().__init__(name,sex)self.has_tail=Falsedef read(self):print(self.name+" is reading")
class Cat(Mammal):def __init__(self, name, sex):super().__init__(name,sex)self.has_tail=Truedef scratch_sofa(self):print(self.name+" is scratching sofa")def poop(self):print(self.name+" is pooping in sand")cat1=Cat("Kitty","girl")
human1=Human("xiao zhang","boy")
cat1.breathe()
human1.read()
cat1.poop()
if human1.has_tail:print(human1.name+' has tail')
else:print(human1.name + ' has no tail')
class Employee:def __init__(self,name,id):self.name=nameself.id=iddef print_info(self):print(f"employ_name is {self.name},employee_id is {self.id}")
class FullTimeEmployee(Employee):def __init__(self,name,id,monthly_salary):super().__init__(name,id)self.monthly_salary=monthly_salarydef calculate_monthly_pay(self):return self.monthly_salary# print(f"{self.name}'s monthly pay is {self.monthly_salary}")
class PartTimeEmployee(Employee):def __init__(self,name,id,daily_salary,work_days):super().__init__(name,id)self.daily_salary=daily_salaryself.work_days=work_daysdef calculate_monthly_pay(self):return self.daily_salary*self.work_days#monthly_pay= float(self.daily_salary)*int(self.work_days)#print(f"{self.name}'s monthly pay is {monthly_pay:.3f}")partE1=PartTimeEmployee("小李","1001",100.0111,20)
FullE1=FullTimeEmployee("小张","2001",9000)
print(f"{partE1.name}的月工资为{partE1.calculate_monthly_pay()}")
print(f"{FullE1.name}的月工资为{FullE1.calculate_monthly_pay()}")
# partE1.calculate_monthly_pay()
# FullE1.calculate_monthly_pay()

文件读写

# f=open("./example.txt","r",encoding="utf-8")
#print(f.read())
#print(f.read(10))
#print(f.readline())
# line=f.readline()
#
# while line !="":
#     print(line)
#     line=f.readline()
#print(f.readlines())
# lines=f.readlines()
# for line in lines:
#     print(line)
# f.close()with open("./example.txt","r",encoding="utf-8") as f:print(f.read())
# with open("./data.txt","w",encoding="utf-8") as f :
#     f.write("hello\n")
#     f.write("world!")
# with open("./data.txt","w",encoding="utf-8") as f :
#     f.write("2hello\n")
#     f.write("2world!")
# with open("./data.txt","a",encoding="utf-8") as f :
#     f.write("hello\n")
#     f.write("world!\n")
# with open("./data.txt","a",encoding="utf-8") as f :
#     f.write("2hello\n")
#     f.write("2world!")
with open("./data.txt","r+",encoding="utf-8") as f :print(f.read())f.write("\nhello\n")f.write("world!")
with open("./poem.txt","w",encoding="utf-8") as f : 
#也可以用转义符\\来表示反斜杠,即文件目录为.\poem.txt
#with open(".\\poem.txt","w",encoding="utf-8") as f : 我欲乘风归去有孔炯楼宇与高处不胜寒""")f.write("""\n起舞弄清影何似在人间""")
with open("./poem.txt", "a", encoding="utf-8") as f :f.write("\nhahaha")

exception

try:user_weight=float(input("请输入体重:"))user_height=float(input("请输入升高:"))user_BMI=user_weight/user_height**2
# except ValueError:
#     print("输入应为数字")
# except ZeroDivisionError:
#     print("身高不能为零")
except:print("输入错误")
else:print ("BMI=",user_BMI)
finally:print("程序结束")

unittest

  1. 被测试的目标类

#file name is "my_calculator.py"
class MyCalculator :def __init__(self,x,y):self.x=xself.y=ydef my_adder(self):return self.x+self.ydef my_multiply(self):return self.x*self.y
  1. 测试脚本
import unittest
from my_calculator import MyCalculator
class TestMyCalculator(unittest.TestCase):def setUp(self):self.calculator=MyCalculator(3,4)# def test_right(self):#     calculator=MyCalculator(3,4)#     self.assertEqual(calculator.my_adder(),7)# def test_wrong(self):#     calculator = MyCalculator(3, 4)#     self.assertEqual(calculator.my_adder(),8)def test_1(self):self.assertEqual(self.calculator.my_adder(),7)def test_2(self):self.assertEqual(self.calculator.my_adder(),8)def test_3(self):self.assertEqual(self.calculator.my_multiply(),11)
  1. 运行测试
Windows PowerShell
版权所有(C) Microsoft Corporation。保留所有权利。安装最新的 PowerShell,了解新功能和改进!https://aka.ms/PSWindows(.venv) PS D:\PycharmProjects\PythonProject\Python_For_Beginners> python -m unittest
.FF
======================================================================
FAIL: test_2 (test_calculator.TestMyCalculator.test_2)
----------------------------------------------------------------------
Traceback (most recent call last):File "D:\PycharmProjects\PythonProject\Python_For_Beginners\test_calculator.py", line 17, in test_2     self.assertEqual(self.calculator.my_adder(),8)
AssertionError: 7 != 8======================================================================
FAIL: test_3 (test_calculator.TestMyCalculator.test_3)
----------------------------------------------------------------------
Traceback (most recent call last):File "D:\PycharmProjects\PythonProject\Python_For_Beginners\test_calculator.py", line 20, in test_3     self.assertEqual(self.calculator.my_multiply(),11)
AssertionError: 12 != 11----------------------------------------------------------------------
Ran 3 tests in 0.002sFAILED (failures=2)
(.venv) PS D:\PycharmProjects\PythonProject\Python_For_Beginners> 

函数作为参数调用,高阶函数,匿名函数

def calculate_square(num):return  num*numdef calculate_cube(num):return num**3def calculate_times_5(num):return num*5def calculate_plus_5(num):return num+5def calculate_and_print(num,calculator):result= calculator(num)print(f"""| 数字参数 |{num}|| 计算结果 |{result}|""")calculate_and_print(10,calculate_times_5)
calculate_and_print(10,calculate_plus_5)
calculate_and_print(10,lambda num:num**2+2)
原文地址:https://blog.csdn.net/alva_xu/article/details/146452458
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mrgr.cn/news/95640.html

相关文章:

  • 介绍一款基于MinerU的PDF翻译工具
  • Qt开发:QComboBox的使用
  • AI知识补全(一):tokens是什么?
  • go中的文件、目录的操作
  • 多阶段构建实现 Docker 加速与体积减小:含文件查看、上传及拷贝功能的 FastAPI 应用镜像构建
  • 【STM32】SPI通信外设硬件SPI读写W25Q64
  • Nginx请求头Hos头攻击
  • Ubuntu20.04安装并配置Pycharm2020.2.5
  • C++模板编程与元编程面试题及参考答案(精选100道题)
  • 车道保持中车道线识别
  • 圆弧插补相关算法汇总(C++和ST源代码)
  • 银河麒麟桌面版包管理器(四)
  • 银河麒麟桌面版包管理器(五)
  • 如何解决微服务调用链性能问题(优化 JVM 配置,降低 Full GC 频率)
  • 虚幻基础:UI
  • 论文阅读笔记:Denoising Diffusion Probabilistic Models (3)
  • 二叉树的学习
  • PowerShell 终端环境自动化配置
  • Ubuntu修改Swap交换空间大小
  • 长短期记忆网络:从理论到创新应用的深度剖析