摘要:问题描述:在PyCharm终端模式执行python脚本报错:ModuleNotFoundError: No module named 'lib.apilib',在该模块下鼠标右击点击Run执行没问题。 解决方法:在导入模块前,将项目地址增加到系统环境变量(该系统环境变量是临时的,只有在执行该pyth
阅读全文
摘要:# coding=utf-8 '''定义一个方法get_num(num),num参数是列表类型,判断列表里面的元素为数字类型。其他类型则报错, 并且返回一个偶数列表:(注:列表里面的元素为偶数)。''' def get_num(*num): null_list = [] for l in num: if type(l) != list: r...
阅读全文
摘要:# 求最大值 def large(*num): # 定义一个large函数,函数的参数为可变参数 ma = num[0] # 初始化最大值 for n in num: if ma < n: # 对参数进行两两比较 ma = n # 对最大值重新赋值 return ma # 返回最大值 print(large(-2...
阅读全文
摘要:#找出水仙花数 def sxh(start, end): if end >= start and start >=100 and end<= 999: num=start #将num的值初始化 L =[] while num<=end: x=num%10 #num取个位数 y=num...
阅读全文