Furqan

Python 3 Find Difference Between Two Lists Using set() Method

Python 3 Find Difference Between Two Lists Using set() Method

code1.py # Python code t get difference of two lists # Using set() def Diff(li1, li2): return list(set(li1) - set(li2))…

July 6, 2022

Python 3 Find Difference Between Two Dates in Hours, Minutes & Seconds

code.py import datetime data1 = datetime.datetime.now() data2 = datetime.datetime.now() diff = data2 - data1 days, seconds = diff.days, diff.seconds hours…

July 6, 2022

Python 3 Find Difference Between Two Dates in Years, Months, Days, Hours, Minutes & Seconds

code.py import datetime from dateutil.relativedelta import relativedelta a = '2014-05-06 12:00:56' b = '2013-03-06 16:08:22' start = datetime.datetime.strptime(a, '%Y-%m-%d %H:%M:%S')…

July 6, 2022

Python 3 Find Difference Between Two Timestamps in Milliseconds

code.py from datetime import datetime date_1 = '24/7/2021 11:13:08.230010' date_2 = '24/7/2021 11:14:18.333338' date_format_str = '%d/%m/%Y %H:%M:%S.%f' start = datetime.strptime(date_1,…

July 6, 2022

Python 3 Pandas Code to Find the Difference Between Two Datetimes in Milliseconds

main.py import pandas as pd from datetime import datetime date_1 = '2/7/2021 21:55:12.230010' date_2 = '24/9/2023 11:13:08.333338' date_format_str = '%d/%m/%Y…

July 6, 2022

Python 3 Find Difference Between Two Tuples in Command Line

main.py a=(1,2,3,4) b=(2,3,5,6) print(tuple(set(a) ^ set(b)))

July 6, 2022

Python 3 Code to Find Difference Between Two Sets Using (-) Operator & difference() Method

main1.py A = {'a', 'b', 'c', 'd'} B = {'c', 'f', 'g'} # Equivalent to A-B print(A.difference(B)) # Equivalent to…

July 6, 2022

WLST Code to Check the Deployment Status of Weblogic Servers

main.py def serversRunningStatus(): #Get list of servers in current domain servers = cmo.getServers() print "Server status in current domain: "…

July 6, 2022

Python 3 Code to Check Whether a Key Exists in a Dictionary

main.py d = {1: 10, 2: 20, 3: 30, 4: 40, 5: 50, 6: 60} def is_key_present(x): if x in…

July 6, 2022

Python 3 Code to Find the Longest Word or String inside List

main.py a_list = ["a_string", "the_longest_string", "string"] longest_string = max(a_list, key=len) print(longest_string)

July 6, 2022