- 博客(8)
- 收藏
- 关注
原创 python:UnboundLocalError: local variable ‘hcf‘ referenced before assignment
示例:def hcf(x, y): """该函数返回两个数的最大公约数""" # 获取最大值 if x > y: x,y=x,y else: x,y=y,x list=[] for i in range(1,x):改为for i in range(1,x+1): if (y * i % x == 0) : list.append(i*y) print(
2022-01-29 14:26:52 1159
原创 python:求最大公约数
def hcf(x, y): """该函数返回两个数的最大公约数""" # 获取最小值 if x > y: smaller = y else: smaller = x list = [] for i in range(1, smaller + 1): if (x % i == 0) and (y % i == 0): list.append(i) hcf .
2022-01-29 14:01:46 1932
原创 python:ASCII码到字符之间的转换
i = input('请输入一个字符:')try: j = int(input('请输入一个ascii码:'))except: print('请输入一个正整数!')print(i + '对应的ASCII码为:', ord(i))print(j, '对应的字符为:', chr(j))
2022-01-29 13:30:21 2517
转载 OMP: Error #15: Initializing libiomp5md.dll, but found libiomp5md.dll already initialized.OMP: Hint
解决方法:方法一:添加下列代码import osos.environ["KMP_DUPLICATE_LIB_OK"]="TRUE"方法二:pycharm用的anaconda的python环境直接pip install --upgrade numpy升级包
2022-01-27 22:45:47 120
原创 Python变量之间的转换
# 变量之间的转换a = input('输入第一个变量:')b = input('输入第二个变量:')# 使用中间变量tem=aa=bb=temprint('交换后的值:{}'.format(a))print('交换后的值:{}'.format(b))# 不使用中间变量a, b = b, aprint()print('交换后的值:{}'.format(a))print('交换后的值:{}'.format(b))...
2022-01-25 20:52:17 712
原创 随机数字random用法
import randomi = 0a = int(input('输入的整数为:'))b = random.randint(0, 1)print('随机生成的数字为:', b)while True: i += 1 if a == b: print('第%d次输入对了!' % i) break else: a = int(input('请再次输入一个整数: '))...
2022-01-25 20:19:46 250
原创 type object ‘h5py.h5.H5PYConfig‘ has no attribute ‘__reduce_cython__‘
问提描述:在环境keras=2.2.5,TensorFlow=1.14中,运行发现有h5py和numpy的报错。解决方法:卸载h5py,pip uninstall h5py总结:安装包之间版本不对应。参考:AttributeError: type object ‘h5py.h5.H5PYConfig‘ has no attribute ‘__reduce_cython__‘问题解决。_zhanghao_0517的博客-CSDN博客...
2022-01-24 20:29:41 2958
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人