-1: newstr = int(value.find("\\")) print newstr pri-6ren">
gpt4 book ai didi

未打印python子字符串

转载 作者:太空宇宙 更新时间:2023-11-04 10:53:43 25 4
gpt4 key购买 nike

我不知道这部分代码有什么问题

if value.find("\\") > -1:
newstr = int(value.find("\\"))
print newstr
print value
print value[newstr:7]

newstrvalue 都被正确打印,但是 value[newstr:7] 显示空白。

有什么想法吗?

最佳答案

value[newstr:7] 会给你从位置 newstr 到位置 7

也许你的意思是 value[newstr:newstr + 7]

关于未打印python子字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11722854/

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