Cut Python strings!

Asked 2 years ago, Updated 2 years ago, 19 views

/url?q=http://news.khan.co.kr/kh_news/khan_art_view.html%3Fartid%3D201609071726232%26code%3D900303&sa=U&ved=0ahUKEwjoyIyA-azZAhUBxJQKHcUsAdEQFgg9MAk&usg=AOvVaw1RSpZpTtFdousoApHGk4-n

I only want to print from http:/ to & from the following string: I tried using the split, but I think it only works once Is there any other way?

python

2022-09-22 20:42

1 Answers

text = "/url?q=http://news.khan.co.kr/kh_news/khan_art_view.html%3Fartid%3D201609071726232%26code%3D900303&sa=U&ved=0ahUKEwjoyIyA-azZAhUBxJQKHcUsAdEQFgg9MAk&usg=AOvVaw1RSpZpTtFdousoApHGk4-next"

a = text.find('http:/')
b = text.find('&')

print(text[a:b])

Results

http://news.khan.co.kr/kh_news/khan_art_view.html%3Fartid%3D201609071726232%26code%3D900303

Are you sure you want to print this out?


2022-09-22 20:42

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.