python - 在 int 中查找 double

标签 python

如果我有整数 1988,如何迭代它来查看是否有 double ?在Python中。

我知道我不能像这样迭代它:

userInt = 1988
for i in userInt:
    print(i)

最佳答案

您可以将其转换为字符串:

userInt = 1988
for i in str(userInt):
    print(i)

如果您想查看是否有 double ,请执行以下操作:

has_doubles = len(set(str(userInt))) == len(str(userInt))

关于python - 在 int 中查找 double ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35931906/

相关文章:

python - Flask 如何将@login_required 重定向到特定路由?

python - 有没有什么办法可以用扭曲的方式异步发布一些数据?

python - pandas.DataFrame.resample 的高斯核密度平滑?

python - 一维 numpy 数组,对于新二维数组中的每个连续行向右移动

python - 从 AWS EKS 中的服务账户代入 AWS 角色

python - 分布式本地聊天服务器

python - 如何修复请求(urllib3)与应用引擎一起工作?

python - Numpy 中的多维索引

python - 使用 scapy 查找 tcp 流

python - Plotly:如何重命名 plotly 表达堆叠条形图的图例元素?