【发布时间】:2021-10-22 18:38:22
【问题描述】:
get_code="https://localhost:8080/soieurow/KPP/alksdjfhlkjhekajhf?eowuiro=akleireyi&URL=https%3A%2F%2Flocalhost:8080%2Fmga%2Fsps%2Foauth%2Foauth20%2Fauthorize%3Fresponse_type%3Dcode%26scope%3Dopenid%2Bname%2Bemail%2Bpostal_code%26client_id%3Dthaljlwej%26redirect_uri%3Dhttp%3A%2F%2Faklsdjfhwekdisd.com%3A5006%2Fredirectcode%26nonce%3DQJT8RbymFk%26acrakdjasd%3DD1%26token%3DfkasjfhalskfhlaksjhkL61bqqADtekpH-HE55lZaX2LJH4Ii9diraseufhalksfhl%26correlation_id%3D4102479872341%26support_encryption%3Dsj2aljkadfj3%26state%3Dajk1234"
code='code'
if code in get_code:
code=get_code.split("code=")[1][:47]
print("i havce code",code)
else:
print("i don't find code")
我正在传递字符串,但出现 IndexError: list index out of range
【问题讨论】:
-
请不要有代码图片。
-
你最好放实际代码而不是图像,我们看不到字符串值:)
-
code=没有出现在您显示的要拆分的字符串中,在这种情况下,索引 1 处将没有元素。 -
分享实际代码,以便我们提供帮助
标签: python list index-error