TypeError: integer argument expected got float' Python 3.6

运行python代码时报错:

Traceback (most recent call last):
  File "D:/PycharmProjects/3D_SD/video_action/video_resize.py", line 34, in
    video_resize(video)
  File "D:/PycharmProjects/3D_SD/video_action/video_resize.py", line 15, in video_resize
    video_writer = cv2.VideoWriter(video_path_resize, cv2.VideoWriter_fourcc('M', 'J', 'P', 'G'), fps, resized_size)
TypeError: integer argument expected, got float
 

错误的意思是:

期望得到的是整数,而你却得到了浮点数

原因:

我的代码中有这么一句:

resized_size =(size[0]/2, size[1]/2)

python3中的整除应该是//,而不是/

所以代码中的/得到的是浮点数,所以会出错

将/改成//就不会报错了!

你可能感兴趣的:(python笔记)