Здравствуйте, форумчане.
Использую ОС xubuntu 20.04 и python версии 3.8. Отправляю post запрос на url в формате json, где один из параметров представляет булево значение ("encrypt": true), но интерпритатор позволяет передавать только как строку.
Мой код:
Есть возможность какого-то явного преобразования? Или какие-либо иные способы?
Package Version
---------------------------- -------------
apturl 0.5.2
blinker 1.4
catfish 1.4.13
certifi 2019.11.28
chardet 3.0.4
command-not-found 0.3
cryptography 2.8
cupshelpers 1.0
dbus-python 1.2.16
defer 1.0.6
distro 1.4.0
distro-info 0.23ubuntu1
entrypoints 0.3
httplib2 0.14.0
idna 2.8
keyring 18.0.1
language-selector 0.1
launchpadlib 1.10.13
lazr.restfulclient 0.14.2
lazr.uri 1.0.3
lightdm-gtk-greeter-settings 1.2.2
menulibre 2.2.1
mugshot 0.4.2
netifaces 0.10.4
oauthlib 3.1.0
olefile 0.46
onboard 1.4.1
pexpect 4.6.0
Pillow 7.0.0
pip 20.0.2
psutil 5.5.1
pycairo 1.16.2
pycups 1.9.73
PyGObject 3.36.0
PyJWT 1.7.1
pymacaroons 0.13.0
PyNaCl 1.3.0
python-apt 2.0.0
python-dateutil 2.7.3
python-debian 0.1.36ubuntu1
PyYAML 5.3.1
reportlab 3.5.34
requests 2.22.0
requests-unixsocket 0.2.0
SecretStorage 2.3.1
setuptools 45.2.0
sgt-launcher 0.2.5
simplejson 3.16.0
six 1.14.0
ssh-import-id 5.10
systemd-python 234
ubuntu-advantage-tools 20.3
ubuntu-drivers-common 0.0.0
ufw 0.36
unattended-upgrades 0.1
urllib3 1.25.8
wadllib 1.3.3
wheel 0.34.2
xcffib 0.8.1
xkit 0.0.0
---------------------------- -------------
apturl 0.5.2
blinker 1.4
catfish 1.4.13
certifi 2019.11.28
chardet 3.0.4
command-not-found 0.3
cryptography 2.8
cupshelpers 1.0
dbus-python 1.2.16
defer 1.0.6
distro 1.4.0
distro-info 0.23ubuntu1
entrypoints 0.3
httplib2 0.14.0
idna 2.8
keyring 18.0.1
language-selector 0.1
launchpadlib 1.10.13
lazr.restfulclient 0.14.2
lazr.uri 1.0.3
lightdm-gtk-greeter-settings 1.2.2
menulibre 2.2.1
mugshot 0.4.2
netifaces 0.10.4
oauthlib 3.1.0
olefile 0.46
onboard 1.4.1
pexpect 4.6.0
Pillow 7.0.0
pip 20.0.2
psutil 5.5.1
pycairo 1.16.2
pycups 1.9.73
PyGObject 3.36.0
PyJWT 1.7.1
pymacaroons 0.13.0
PyNaCl 1.3.0
python-apt 2.0.0
python-dateutil 2.7.3
python-debian 0.1.36ubuntu1
PyYAML 5.3.1
reportlab 3.5.34
requests 2.22.0
requests-unixsocket 0.2.0
SecretStorage 2.3.1
setuptools 45.2.0
sgt-launcher 0.2.5
simplejson 3.16.0
six 1.14.0
ssh-import-id 5.10
systemd-python 234
ubuntu-advantage-tools 20.3
ubuntu-drivers-common 0.0.0
ufw 0.36
unattended-upgrades 0.1
urllib3 1.25.8
wadllib 1.3.3
wheel 0.34.2
xcffib 0.8.1
xkit 0.0.0
Использую ОС xubuntu 20.04 и python версии 3.8. Отправляю post запрос на url в формате json, где один из параметров представляет булево значение ("encrypt": true), но интерпритатор позволяет передавать только как строку.
Мой код:
Python:
import requests
import json
url = 'http://192.168.150.9:8081'
headers = {'Content-type': 'application/json'}
data = {
"id": "1234",
"data": "E58mW+caXjaws0UdeZgk9dqT+4IblruppK6mpwcrxpGr4fi",
"encrypt": "true", #пробовал bool(true) и 'true'
"uid": "MDE1NjkzNTM4ME3Nw=="},
answer = requests.post(url, data=json.dumps(data), headers=headers)
print(answer)
response = answer.json()
print(response)
Есть возможность какого-то явного преобразования? Или какие-либо иные способы?