码迷,mamicode.com
首页 >  
搜索关键字:def    ( 28626个结果
aiohttp使用方法
import aiohttp import asyncio async def request_jd_comment(session): url = "http://httpbin.org/ip" proxy = "http://14.67.8.20:2045" # 这里的代理参数是proxy,内容 ...
分类:Web程序   时间:2020-12-04 11:36:10    阅读次数:14
LeetCode #1389. Create Target Array in the Given Order
###题目 1389. Create Target Array in the Given Order ###解题方法 创建一个新数组rat,将nums中的数按照index的位置插入rat即可。 时间复杂度:O(n*n) 空间复杂度:O(n) ###代码 class Solution: def cre ...
分类:其他好文   时间:2020-12-04 11:06:02    阅读次数:6
python中的函数
函数 #什么函数 函数就是有某个具体功能的工具 函数必须先定义,后面才能调用,并且在任意位置调用 #为什么要用函数 减少某一特定功能的代码冗余 使函数的调用更加方便,提高开发效率 提高程序的扩展性 #定义函数 #使用关键字 def #函数名与变量名类似,命名规则相同 #该过程不会执行代码,只会检测语 ...
分类:编程语言   时间:2020-12-04 11:04:42    阅读次数:3
装饰器、生成式、迭代器
def my_sum(x,y): return x+y res = my_sum(1,2) print(res) 函数对象 #函数名是第一类对象: 函数名指向的值可以被当作参数传递(类似于变量) name = 'syy' x = name print(x) #syy print(id(x)) #25 ...
分类:其他好文   时间:2020-12-04 11:03:30    阅读次数:4
四则运算
def problem(area=10): # 随机生成一道题目(自然数四则运算或分数运算),运算符不超过3个 try: if random.choice([1, 2]) == 1: # 随机生成 自然数或分数 的四则运算 expression, print_expression = natural ...
分类:其他好文   时间:2020-12-04 10:58:33    阅读次数:8
小学四则运算
#运行代码: import random 四则运算 def t(): sym = ['+', '-', '×', '÷'] f= random.randint(0, 3) n1 = random.randint(1, 20) n2 = random.randint(1, 20) result = 0 ...
分类:其他好文   时间:2020-12-04 10:51:23    阅读次数:6
四则运算
import randomimport mathimport fractionsq=[]ans=[]def c1(q,ans) symble = random.choice(['+','-','*','/']) if symble == '+': n1 = random.randint(0,20) ...
分类:其他好文   时间:2020-12-04 10:49:38    阅读次数:6
小学四则运算编程实践
1 import random#导入随机库 2 from fractions import Fraction#导入分数运算 3 ##整数运算 4 def c1(q, ans): 5 operator = random.choice(['+', '-', '*', '/']) # 生成运算符 6 if ...
分类:其他好文   时间:2020-12-03 12:26:32    阅读次数:16
小学四则运算
代码如下: import random #四则运算 def t(): sym = ['+', '-', '×', '÷'] f= random.randint(0, 3) n1 = random.randint(1, 20) n2 = random.randint(1, 20) result = 0 ...
分类:其他好文   时间:2020-12-03 12:25:51    阅读次数:10
小学四则运算
##运行截图如下 ##参考代码如下 import random #四则运算 def t(): sym = ['+', '-', '×', '÷'] f= random.randint(0, 3) n1 = random.randint(1, 20) n2 = random.randint(1, 20 ...
分类:其他好文   时间:2020-12-03 12:24:39    阅读次数:11
28626条   上一页 1 ... 76 77 78 79 80 ... 2863 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!