Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/296.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python数据分析序列号_Python_Python 3.x - Fatal编程技术网

Python数据分析序列号

Python数据分析序列号,python,python-3.x,Python,Python 3.x,嗨,我有一个序列号,例如204567,6个数字中的每个数字都有子集数据。有没有一种方法可以在python中对每个数字进行加密?来自math import floor from math import floor def check_if_number_exists(number, digit_to_find): # check if the number is positive if number < 0: Number = -number els

嗨,我有一个序列号,例如204567,6个数字中的每个数字都有子集数据。有没有一种方法可以在python中对每个数字进行加密?

来自math import floor
from math import floor

def check_if_number_exists(number, digit_to_find):
    # check if the number is positive
    if number < 0:
        Number = -number
    else:
        Number = number
    while(Number != 0):
        # run loop for extracting each digit
        Digit = Number % 10 # gives the last number
        Number = floor(Number / 10) # removing the last digit
        if Digit == digit_to_find:
            print("the number contains " + str(digit_to_find) + ' in ' + str(number))
            break


#                      sequencenumber, number_to_check                    
check_if_number_exists(45638, 3)
def检查是否存在数字(要查找的数字): #检查数字是否为正数 如果数字<0: 数字=-数字 其他: 数字=数字 while(Number!=0): #运行循环提取每个数字 数字=数字%10#给出最后一个数字 数字=楼层(数字/10)#删除最后一位数字 如果数字=要查找的数字: 打印(“数字包含”+str(数字)+'in'+str(数字)) 打破 #序列号,编号到检查 检查号码是否存在(45638,3)

还有另一种方法,您可以将数字转换为字符串,然后检查字符串的每个元素

将其转换为字符串
str(204567)
,然后可以一次循环一个字符。