Skip to main content

Posts

Showing posts with the label PYTHON

Data Types in Python

Data Types  In C# or Java, You need to declare a variable specify them integer, string, and decimal. But in Python no need to specify. We can declare variables like Example: C# or Java int age = 28; string Name = "Siddhu"; Example: Python age = 28 Name = "Siddhu" So, you don't need to declare variable types in python. This is an advantage in Python, But still have few Disadvantages too. Example: In my Python function def add_numbers(x,y): print(x+y) add_numbers(20,50) //Output: 70 add_numbers(20,"Something") //Error:"Traceback (most recent call last): File "C:/Users/siddhartha.e/PycharmProjects/siddhu-py/my1stpycode.py", line 8, in add_numbers(50,"Something") File "C:/Users/siddhartha.e/PycharmProjects/siddhu-py/my1stpycode.py", line 4, in add_numbers print(a + b) TypeError: unsupported operand type(s) for +: 'int' and 'str'" ...

Sending HTTP Requests through Proxy Server using Python

In most cases, you have sent a request using the proxy to connect client server. because you do not have direct access to connect those servers. Or they can accept only the requests of their country. First, we need to import Requests library.  Requests is an elegant and simple HTTP library for Python. import requests proxies = { "https": "171.255.192.118:8080", "http" : "171.255.192.118:8080" } #Check your present IP address url = "http://httpbin.org/ip" ip = requests.get(url) r = ip.json() print (r) #Connect Proxy server ip = requests.get(url, proxies=proxies) r = ip.json() print (r) #OUTPUT {'origin': '125.62.194.242'} {'origin': '171.255.192.118'} If you want proxy server ip address and port numbers, you can follow this link proxies