Env files allow you to put your environment variables inside a file. You just create a new file called. env in your project and slap your variables in there on different lines. This env is used for storing your all id, password, keys all important credential so no on directly can get your data. Code Step 1: Create a virtual environment and make it active Step 2: pip install python-dotenv Step 3: Create a .env file Step 4: Create test.py in the same dir where you created .env file Now Check Code test.py from dotenv import load_dotenv load_dotenv() import os my_site = os.getenv("DOMAIN") print("Visit My website : {} ".format(my_site)) .env # a comment that will be ignored. DOMAIN= https://thepyuniverse.blogspot.com Now Run test.py Output: Visit My website : https://thepyuniverse.blogspot.com Screenshot : Quiz Level 1 Quiz Level 2 Request Me
Code Example # Create a Large file for Test Data Processing This below code will create 1.1GB .txt file import string from random import choice with open("large_data.txt", "w") as fp: i = 1 while i <= 1000000: word = (''.join( choice(string.ascii_uppercase + string.digits) for _ in range(10)) + "|" ) * 100 fp.write(word[:] + "\n") i += 1
Practice Set 1 01) How Python code Execute? 02) Why Python is interpreted language? 03) Why Python is known as a scripting language? 04) What is PVM? 05) How Python manages its memory? 06) What is namespace in Python? 07) What are built-in data types in Python? 08) What is literal? 09) What is docstring? 10) How to create a custom datatype in Python? 11) What is the difference between List, Tuple, and Set? 12) What is faster between List and Tuple? Explain Why? 13) What is the difference between Python List and Array? In both cases how memory allocates? 14) If I want to update a Tuple how can I do it? 15) How many types of dictionaries present in Python? 16) What is the difference between Dict and OrderDict? 17) What is the advantage of using Dict? 18) You have a list how can you make sure all the elements in the list should be unique? 19) What is mo...
Comments
Post a Comment