Posting Data In Python

Introduction

 
In this blog, I am going to show how to post data into a demo form in Python. It will post the user data into a demo form in the web browser.
 
Software requirement
 
Python 3.5 and IDLE (Python 3.5) or above
 
Programming code
  1. #Posting data in Python  
  2. #import packages  
  3. import requests  
  4. #post data  
  5. mydata={"name":"raj""email""pr@gmail.com"}  
  6. #request  
  7. r=requests.post("https://www.w3schools.com/php/welcome.php", data=mydata)  
  8. #output statement  
  9. f=open("myfile.html","w+")  
  10. f.write(r.text)  
About the code
 
First, I am importing the request modules.
 
Next, set posting data and request to a demo form page.
 
Finally, I have written the output statement to show the result in a web browser. Then, let’s execute the code.
 
Form
 
 
 
Before executing the code.
 
 
After executing the code.
 
 
Next Recommended Reading Posting JSON In Python