如何将字符串散列为 4 位数,其值高于 1000 且低于 9999?
How to hash a string into 4 digits with values above 1000 and below 9999?
有什么方法可以将某个字符串的散列生成为 > 1000
和 <= 9999
的 4 位整数?
来自 barmar 的想法:
datainput = input("Enter a string : ")
hashoutput = (hash(datainput) % 8999) + 1001
print(hashoutput)
有什么方法可以将某个字符串的散列生成为 > 1000
和 <= 9999
的 4 位整数?
来自 barmar 的想法:
datainput = input("Enter a string : ")
hashoutput = (hash(datainput) % 8999) + 1001
print(hashoutput)