2016-12-31 87 views
0

我使用请求PHP没有返回完整的数据备份到Python

r = requests.post('http://localhost:8000/python-data', data = data) 在数据字典中的格式如下

{'IN545ELFIBP3NAFAMZ': {'url': 'https://www.example.com/infinix-zero-4-x555-32gb-golden-4g-lte-6453687.html', 'color': 'Golden', 'image_url': 'https://example.com/p/infinix-7770-7863546-1-catalog_grid_3.jpg', 'brand': 'Infinix', 'title_alt': 'Zero 4 X555 - 32GB - Golden - 4G LTE', 'currency': 'Rs.', 'current_price': '22,999', 'old_price': 0, 'discount_percent': 0, 'rating_percent': 'width: 82%', 'total_ratings': '20'}, 'LE650EL10B3WSNAFAMZ': {'url': 'https://www.example.com/lenovo-zuk-z1-64gb-grey-6448906.html', 'color': 'Grey', 'image_url': 'https://example.com/p/lenovo-9978-6098446-1-catalog_grid_3.jpg', 'brand': 'Lenovo', 'title_alt': 'ZUK Z1 - 64GB - Grey', 'currency': 'Rs.', 'current_price': '36,999', 'old_price': 0, 'discount_percent': 0, 'rating_percent': 'width: 85%', 'total_ratings': '5'}} 

有数据如下格式发送数据给我laravel的应用程序,我回国完整的数据回蟒蛇

public function save(Request $request){ 
     return $request->all(); 
    } 

但是当我打印蟒蛇返回的数据,这是我得到 print(r.text) {"IN545ELFIBP3NAFAMZ":"total_ratings","LE650EL10B3WSNAFAMZ":"total_ratings"}

+1

首先检查您在PHP中收到的内容。 – furas

+0

@furas php本身没有收到正确的数据。 –

+0

我认为现在人们在stackoverflow只是来downvote你的问题,而不是回答它。拜托朋友,如果你不知道答案,那么你为什么要下调? –

回答

0

花费数个小时后,唯一的问题是,我不得不将数据发送为JSON

r = requests.post('http://localhost:8000/python-data', json = data) 它工作得很好。