简体   繁体   English

如何将 hash 字符串转换为 4 位数字,其值高于 1000 且低于 9999?

[英]How to hash a string into 4 digits with values above 1000 and below 9999?

Any method to generate a hash of some string into a 4 digit int that's > 1000 and <= 9999 ?将某个字符串的 hash 生成为> 1000<= 9999的 4 位整数的任何方法?

From barmar's idea:从barmar的想法:

datainput = input("Enter a string : ")
hashoutput = (hash(datainput) % 8999) + 1001
print(hashoutput)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM