Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python search in json file

def search(key, value, json_file):
    """
    Function that will  search in json file

    Args:
        key: key to search
        value: value to search
        json_file: the file to search

    Returns:

    """
    with open(json_file, 'r') as file:
        data = json.load(file)
        for item in data:
            if item[key] == value:
                return True
        return False
Comment

PREVIOUS NEXT
Code Example
Python :: create bootable usb apple 
Python :: chr() function in python 
Python :: django form field add attrs 
Python :: python regex match 
Python :: python if boolean logic 
Python :: python array of tuples for loop 
Python :: python hash and unhash string 
Python :: fill zeros left python 
Python :: create an empty array numpy 
Python :: Python RegEx Searching for an occurrence of the pattern 
Python :: python multiply each item in list 
Python :: lambda function if else in python 
Python :: listing of django model types 
Python :: why wont my python input accept string inputs 
Python :: how to take input in python as string and convert into integer list 
Python :: coinflip 
Python :: string.format() with {} inside string as string 
Python :: iterating over tuples in python 
Python :: filter dataframe with a list of index 
Python :: pos taggging in nltk 
Python :: sep and end in print python 
Python :: Python program to print positive numbers in a list 
Python :: example of tinker in python 
Python :: text color python tkinter 
Python :: how to convert categorical data to numerical data in python 
Python :: check if digit or alphabet 
Python :: find the sitepckages for anaconda 
Python :: Install pygmt in Anaconda prompt 
Python :: python linux command 
Python :: how to make a random question generator in python 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =