How to convert JSON data into a Python object?

Rajendra Dharmkar
Published on 24-Jan-2018 13:04:43
The following code converts a json object(string) into a python object(dictionary). We import the json module and use the json.loads() method to do this.import json json_string = '{"name":"Sonali", "age": 21, "designation":" Software developer"}' print type (json_string) def func(strng):     a =json.loads(strng)     print type(a)     print a ... Read More

How to use step attribute in HTML?

Smita Kapse
Published on 22-Jan-2018 13:14:51
The HTML input type step attribute sets the legal number intervals. Steps are number steps like 0, 4, 8, 12, 16, etc. The step attribute can be used together with the max and min attributes to create a range of legal values.ExampleYou can try to run the following code to ... Read More

How to use the required attribute in HTML?

Rishi Rathor
Published on 23-Jan-2018 09:36:10
The required attribute in HTML is used o specify that the element should be filled before the form is submitted. If the field isn’t filled and the submit button is clicked, an error generates, which fails form submission. The error will be “Please fill out this field”.The required attribute can ... Read More

How we can convert Python objects into JSON objects?

Rajendra Dharmkar
Published on 24-Jan-2018 12:33:46
Suppose we have a list object a = [1, 2, 3]. We convert a python object into a JSON object by importing json module and using the method json.dumps() as follows.>>> a = [1, 2, 3] >>> import json >>> json.dumps(a) '[1, 2, 3]'The JSON object we got is '[1, ... Read More

How to use placeholder attribute in HTML?

Anvi Jain
Published on 22-Jan-2018 13:00:54
If you want to set a hint for text area or input field, then use the HTML placeholder attribute. The hint is the expected value, which gets displayed before the user enters a value, for example, name, details, etc.ExampleYou can try to run the following code to learn how to ... Read More

Is there any Python object inspector?

Rajendra Dharmkar
Published on 24-Jan-2018 12:15:02
There is no single built-in or normal function that acts as a object inspector in Python. There are functions like type(), dir(), vars() or modules like inspect which can be used to find the attributes, properties and methods of any object under inspection.There other functions like id(), getattr(), hasattr(), globals(), ... Read More

How to use pattern attribute in HTML?

Nitya Raut
Published on 22-Jan-2018 12:53:48
The pattern attribute in HTML is used to set a regular expression in the following input types: text, url, tel, search, date, email, and password. For passwords, with the pattern attribute, you can set the minimum required values. For example, password should have at least 8 characters.ExampleYou can try to ... Read More

What are async methods in JavaScript?

varun
Published on 23-Jan-2018 15:11:11
The async function declaration as the name suggests defines an asynchronous function. This function returns an AsyncFunction object.Here’s the syntax:async function functionname([param[, param[, ... param]]]) {    statements to be executed }ExampleLet’ see an example, which prints the result after 5 seconds:<html>    <body>       <script>     ... Read More

How to use multiple attribute in HTML?

Vrundesha Joshi
Published on 22-Jan-2018 12:23:25
The multiple attribute in HTML allows user to enter more than one value. It is a Boolean attribute and can be used on <input> as well as <select> element, To allow multiple file uploads in HTML forms, use the multiple attribute. The multiple attribute works with email and file input ... Read More

How to return an object from a function in Python?

Rajendra Dharmkar
Published on 24-Jan-2018 12:03:14
The return statement makes a python function to exit and hand back a value to its caller. The objective of functions in general is to take in inputs and return something. A return statement, once executed, immediately halts execution of a function, even if it is not the last statement ... Read More
Advertisements