I'm trying to use Requests to load a .py file from a GitHub directory. The .py file starts like this (I guess it's a dictionary?):
colors = {
"1234": {
"shade": [1, 2, 3]
}
}
I use the following code:
import requests
r = requests.get('https://raw.github.com/example/example1/master/scripts/colors.py')
I would like r to be a variable or a dictionary, so that I can easily look for some specific strings inside. However, when I print r I don't get a .py file, but there are also signs like \r\n etc. How can I read this file properly?
r.text
>>> 'colors = {\r\n\r\n "1234": {\r\n "shade": [1, 2, 3]}\r\n}\r\n'
At the end I would like to create a dictionary, where for "shade" I obtain all values. So first I would need to search r for the word "shade".
I will be thankful for any suggestions and solutions.