whenever browser makes request to a server like google then along with requests it sends additional headers attached with it, so when we make request with bare code (like when using selenium) then such thing is not done so google knows that the request is from code or something like robot. so to prevent it we use a framework like fake_user and import class user_agent that helps in attaching headers
Showing posts with label python. Show all posts
Showing posts with label python. Show all posts
Monday, April 22, 2019
User Agent
whenever browser makes request to a server like google then along with requests it sends additional headers attached with it, so when we make request with bare code (like when using selenium) then such thing is not done so google knows that the request is from code or something like robot. so to prevent it we use a framework like fake_user and import class user_agent that helps in attaching headers
Python Bible
Data Structures in Python
List
list.append(x)- Add an item to the end of the list.
list.extend(iterable)- Extend the list by appending all the items from the iterable.
list.insert(i, x)- Insert an item at a given position.
a.insert(0, x)inserts at the front of the list, anda.insert(len(a), x)is equivalent toa.append(x).
list.remove(x)- Remove the first item from the list whose value is equal to x.
list.pop([i])- Remove the item at the given position in the list, and return it. If no index is specified,
a.pop()removes and returns the last item in the list.
list.clear()- Remove all items from the list.
list.index(x[, start[, end]])- Return zero-based index in the list of the first item whose value is equal to x
list.count(x)- Return the number of times x appears in the list.
list.sort(key=None, reverse=False)- Sort the items of the list in place
list.reverse()- Reverse the elements of the list in place.
list.copy()- Return a shallow copy of the list
-------------------------------------------------------------------------------------------------
Tuples
A tuple is a sequence of immutable Python objects. Tuples are sequences, just like lists. The differences between tuples and lists are, the tuples cannot be changed unlike lists, tuples use parentheses, whereas lists use square brackets.
eg
tup1 = ('physics', 'chemistry', 1997);
tup2 = (1, 2, 3 );
tup3 = "a", "b",;
-------------------------------------------------------------------------------------------------------
Dictionary
A dictionary is a collection which is unordered, changeable and indexed. In Python dictionaries are written with curly brackets, and they have keys and values.
thisdict = {
"brand": "Ford",
"model": "Mustang",
"year": 1964
}
print(thisdict)
"brand": "Ford",
"model": "Mustang",
"year": 1964
}
print(thisdict)










