import requests

S = requests.Session()

URL = "https://test.wikipedia.org/w/api.php"

PARAMS_1 = {
    "action": "query",
    "meta": "tokens",
    "format": "json"
}

R = S.get(url=URL, params=PARAMS_1)
DATA = R.json()

CSRF_TOKEN = DATA['query']['tokens']['csrftoken']

PARAMS_3 = {
    "action": "edit",
    "title": "UserJayprakash12345-Wikimania",
    "token": CSRF_TOKEN,
    "format": "json",
    "appendtext": "Hello"
}

R = S.post(URL, data=PARAMS_3)
DATA = R.json()

print(DATA)
{'edit': {'new': '', 'result': 'Success', 'pageid': 105686, 'title': 'UserJayprakash12345-Wikimania', 'contentmodel': 'wikitext', 'oldrevid': 0, 'newrevid': 400261, 'newtimestamp': '2019-08-14T13:46:47Z'}}
print(1)
1