From 9f0a15e6e7a8fd56813d8f2b2e9a0d59eca61ab9 Mon Sep 17 00:00:00 2001 From: wangershi <33387561+wangershi@users.noreply.github.com> Date: Sun, 5 Nov 2017 15:42:50 +0800 Subject: [PATCH] =?UTF-8?q?Update=20=E4=BA=8C=E7=BB=B4=E6=95=B0=E7=BB=84?= =?UTF-8?q?=E6=9F=A5=E6=89=BE.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 需要判断float是否有小数点,如果有小数点的话float肯定不是整数 --- ...\273\264\346\225\260\347\273\204\346\237\245\346\211\276.py" | 2 ++ 1 file changed, 2 insertions(+) diff --git "a/Target Offer/\344\272\214\347\273\264\346\225\260\347\273\204\346\237\245\346\211\276.py" "b/Target Offer/\344\272\214\347\273\264\346\225\260\347\273\204\346\237\245\346\211\276.py" index 3d05286..81239fd 100644 --- "a/Target Offer/\344\272\214\347\273\264\346\225\260\347\273\204\346\237\245\346\211\276.py" +++ "b/Target Offer/\344\272\214\347\273\264\346\225\260\347\273\204\346\237\245\346\211\276.py" @@ -29,6 +29,8 @@ def Find(self, array, target): # 判断非法输入 # 可以换成 isinstance(target, (int, float)) 进行判断 if type(target) == float and type(array[0][0]) == int: + if int(target) == target: + return False target = int(target) elif type(target) == int and type(array[0][0]) == float: target = float(int)