gpt4 book ai didi

python 指数()不工作

转载 作者:行者123 更新时间:2023-11-28 19:50:29 27 4
gpt4 key购买 nike

我正在尝试在控制台中打印文件名“xyz.0.html”。它吐出一个错误 "substring not found"

目录中的文件:

xyz.0.html
xyz.1.html
xyz.2.html

python

for name in glob.glob('*html'):
if name.index('.0.html'):
print name

最佳答案

为什么不使用 str.endswith()

>>> "xyz.0.html".endswith(".0.html")
True

关于 python 指数()不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11457882/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com