Best Python code snippet using localstack_python
__init__.py
Source: __init__.py
1import time2from pytz import timezone3import nonebot4from nonebot import on_command5from nonebot.adapters import Bot, Event6from nonebot.rule import to_me7from nonebot.typing import T_State8from datetime import datetime91011from .config import Config1213global_config = nonebot.get_driver().config14plugin_config = Config(**global_config.dict())151617Cooky_time = on_command("", priority=5)1819t = time.localtime()20current_time = time.strftime("%H:%M:%S", t)2122format = "%H:%M"232425@Cooky_time.handle()26async def handle_first_receive(bot: Bot, event: Event, state: T_State):27 args = str(event.get_message()).strip() # é¦æ¬¡åéå½ä»¤æ¶è·éçåæ°ï¼ä¾ï¼/æ¶é´ ä¸æµ·ï¼åargs为ä¸æµ·28 if args:29 state["city"] = args.replace("æ¶é´", "") # å¦æç¨æ·åéäºåæ°åç´æ¥èµå¼303132@Cooky_time.got("city", prompt="ä½ æ³æ¥è¯¢åªéçæ¶é´å¢ï¼")33async def handle_city(bot: Bot, event: Event, state: T_State):34 city = state["city"]35 #if city not in ["诺森德", "é¶è²è¯ç¼åº","åé£èå", "ç´¢ææ¥çå°","å¬æ¥æ¹", "å°å å°å·","å°å°ç座","æ¶æ森æ", "é¾éª¨èé", "é£æ´å³å£", "ç¥è¾¾å
","ç°çä¸éµ", "åé£å³¡æ¹¾",36 # "æ´é£å","诺è«çæ ¹","éçå ¡","å¹½æå","é¶æå","èå®æ¹¾","åæµ·é","éçµå¦é¢","æ¯å¦ç´¢å§", "éªéé","æçæ¯æ³é¢å°", "é¶æ¾æ£®æ", "è¾å°æ森æ", "西é¨èé",37 # "西çç«ä¹å°","奥ç¹å
°å
å±±è","å¸å°æ¯å¸è±å¾·ä¸éµ","é¿ææ¯é«å°","丹è«ç½","ç½ç峡谷","çç§å¹³å","èæ£è°·","éé£å°å¾","å¥å°ä¸¹çº³æ¯å²","æ°¸æ森æ","å¹½éä¹å°",38 # "ä¸çç«ä¹å°","è¾ç¹å
°","湿å°","æ´å
è«ä¸¹","èèä¹å°","赤èå±±","æ²ä¼¤æ²¼æ³½","è¯
åä¹å°",39 # "å¥¥æ ¼çç","åé³ç¾¤å²","达纳èæ¯","å åºæ£®","é·éå´","æ³°è¾¾å¸å°","æ¶å
ä¹ç©´","ç§èå²","ç§è¡å²","å索达","æå
æå°","é»æµ·å²¸","ç°è°·","è´¹ä¼å¾·æ£®æ","ç³çªå±±è","ååä¹å°","è²ææ¯","å¸å©èæ¯",40 # "è«é«é·","å®ææ´","åéç³æ","è«é«é·","è´«ç ä¹å°","æµ·å å°å±±","å¬æ³è°·","è¾è¨æ","å°æ³¥æ²¼æ³½","å¡çº³å©æ¯","æéå¡å°",41 # "ä¸æ殿","è³èé«å","ææ§åºå","æè±å±±","é¦ç»£è°·","åé£è°·","å¡æ¡ç
ä¸æ","ç¿¡ç¿ æ","é·ç¥å²",42 # "åºå°æææ¯","伯æåæ¯","å¾·é²æ¯ç¦","æ¯æé¢è°·å°","ææå 德海峡","麦å¡è´¡",43 # "èµè¾¾æ","è¾¾è¨ç½","æ²é¡¿","纳å
¹ç±³å°","ç¥è¾¾è¨","纳æ²å¡å°"44 # "大漩涡","ç§èµ","ç ´ç¢ç¾¤å²"]:4546 # await Cooky_time.reject("ä½ æ³æ¥è¯¢çå°åºæä¸æ¯æï¼è¯·éæ°è¾å
¥ï¼")47 city_time = await get_time(city)48 await Cooky_time.finish(city_time)495051async def get_time(city: str):52 if city in ["æ½è¾¾å©äº","ä¸æ殿" , "é¦ç»£è°·" , "åé£è°·" , "æè±å±±" , "å¡æ¡ç
ä¸æ" , "ç¿¡ç¿ æ" , "诺森德" , "é¶è²è¯ç¼åº" , "æ¶æ森æ" , "é¾éª¨èé" , "é£æ´å³å£" , "ç¥è¾¾å
" , "ç°çä¸éµ" , "åé£å³¡æ¹¾"]:53 now_utc = datetime.now(timezone('UTC'))54 where_time = now_utc.astimezone(timezone('Asia/Shanghai'))55 now_gmt_8 = (where_time.strftime(format))5657 return f"ç°å¨æ¯{city}æ¶é´" + now_gmt_85859 elif city in ["èµè¾¾æ" , "è¾¾è¨ç½" , "æ²é¡¿" , "纳å
¹ç±³å°" , "ç¥è¾¾è¨" , "纳æ²å¡å°"]:60 now_utc = datetime.now(timezone('UTC'))61 where_time = now_utc.astimezone(timezone('Pacific/Auckland'))62 now_gmt_12 = (where_time.strftime(format))6364 return f"ç°å¨æ¯{city}æ¶é´" + now_gmt_126566 elif city in ["åºå°æææ¯" , "伯æåæ¯" , "å¾·é²æ¯ç¦" , "æ¯æé¢è°·å°" , "ææå 德海峡" , "麦å¡è´¡"]:67 now_utc = datetime.now(timezone('UTC'))68 where_time = now_utc.astimezone(timezone('Pacific/Niue'))69 now_gmt_n11 = (where_time.strftime(format))7071 return f"ç°å¨æ¯{city}æ¶é´" + now_gmt_n117273 elif city in ["è³èé«å" , "ææ§åºå" , "åé£èå" , "ç´¢ææ¥çå°" , "å¬æ¥æ¹" , "å°å å°å·" , "å°å°ç座" , "é·ç¥å²" , "大漩涡" , "ç§èµ" , "ç ´ç¢ç¾¤å²"]:74 now_utc = datetime.now(timezone('UTC'))75 where_time = now_utc.astimezone(timezone('Asia/Tokyo'))76 now_gmt_9 = (where_time.strftime(format))7778 return f"ç°å¨æ¯{city}æ¶é´" + now_gmt_97980 elif city in ["ç§èå²" , "ç§è¡å²" , "å索达"]:81 now_utc = datetime.now(timezone('UTC'))82 where_time = now_utc.astimezone(timezone('Europe/London'))83 now_gmt_0 = (where_time.strftime(format))8485 return f"ç°å¨æ¯{city}æ¶é´" + now_gmt_08687 elif city in ["达纳èæ¯" , "æ³°è¾¾å¸å°" , "æå
æå°" , "é»æµ·å²¸" , "ç°è°·" , "è´¹ä¼å¾·æ£®æ" , "ç³çªå±±è" , "ååä¹å°" ,"è²ææ¯" , "å¸å©èæ¯"]:88 now_utc = datetime.now(timezone('UTC'))89 where_time = now_utc.astimezone(timezone('Europe/Berlin'))90 now_gmt_1 = (where_time.strftime(format))9192 return f"ç°å¨æ¯{city}æ¶é´" + now_gmt_19394 elif city in ["è«é«é·" , "å®ææ´" , "åéç³æ" , "è«é«é·" , "è´«ç ä¹å°" , "æµ·å å°å±±" , "å¬æ³è°·" , "é·éå´"]:95 now_utc = datetime.now(timezone('UTC'))96 where_time = now_utc.astimezone(timezone('Europe/Warsaw'))97 now_gmt_2 = (where_time.strftime(format))9899 return f"ç°å¨æ¯{city}æ¶é´" + now_gmt_2100101 elif city in ["è¾è¨æ" , "å°æ³¥æ²¼æ³½" , "å¡çº³å©æ¯" , "æéå¡å°" , "å¥¥æ ¼çç" , "åé³ç¾¤å²" , "å åºæ£®" , "æ¶å
ä¹ç©´"]:102 now_utc = datetime.now(timezone('UTC'))103 where_time = now_utc.astimezone(timezone('Europe/Moscow'))104 now_gmt_3 = (where_time.strftime(format))105106 return f"ç°å¨æ¯{city}æ¶é´" + now_gmt_3107108 elif city in ["æ´é£å" , "诺è«çæ ¹" , "éçå ¡" , "éªéé" , "èå®æ¹¾" , "西é¨èé" , "è¾å°æ森æ" , "æ®è²æ£®æ","æçæ¯æ³é¢å°", "é¶æ¾æ£®æ", "è¾å°æ森æ"]:109 now_utc = datetime.now(timezone('UTC'))110 where_time = now_utc.astimezone(timezone('America/Vancouver'))111 now_gmt_n8 = (where_time.strftime(format))112113 return f"ç°å¨æ¯{city}æ¶é´" + now_gmt_n8114115 elif city in ["å¹½æå" , "åæµ·é" , "éçµå¦é¢" , "西çç«ä¹å°", "奥ç¹å
°å
å±±è" , "å¸å°æ¯å¸è±å¾·ä¸éµ" , "é¿ææ¯é«å°" , "丹è«ç½" , "ç½ç峡谷" , "çç§å¹³å" , "èæ£è°·" , "éé£å°å¾"]:116 now_utc = datetime.now(timezone('UTC'))117 where_time = now_utc.astimezone(timezone('America/Edmonton'))118 now_gmt_n7 = (where_time.strftime(format))119120 return f"ç°å¨æ¯{city}æ¶é´" + now_gmt_n7121122 elif city in ["é¶æå" , "æ¯å¦ç´¢å§" , "å¥å°ä¸¹çº³æ¯å²" , "æ°¸æ森æ" , "å¹½éä¹å°" ,"ä¸çç«ä¹å°" , "è¾ç¹å
°" , "湿å°" , "æ´å
è«ä¸¹" , "èèä¹å°" , "赤èå±±" , "æ²ä¼¤æ²¼æ³½" , "è¯
åä¹å°"]:123 now_utc = datetime.now(timezone('UTC'))124 where_time = now_utc.astimezone(timezone('America/Winnipeg'))125 now_gmt_n6 = (where_time.strftime(format))126127 return f"ç°å¨æ¯{city}æ¶é´" + now_gmt_n6
...
scheduler.py
Source: scheduler.py
1import pendulum2from datetime import datetime, timedelta3class Scheduler:4 class StartDate:5 @staticmethod6 def yesterday():7 now_utc = pendulum.now("utc")8 return now_utc.subtract(days=1, hours=now_utc.hour, minutes=now_utc.minute, seconds=now_utc.second,9 microseconds=now_utc.microsecond)10 @staticmethod11 def yesterday_usa_central_timezone():12 yesterday = pendulum.now("America/Chicago")13 return yesterday.subtract(days=1, hours=yesterday.hour, minutes=yesterday.minute, seconds=yesterday.second,14 microseconds=yesterday.microsecond)15 @staticmethod16 def one_hour_ago():17 now_utc = pendulum.now("utc")18 return now_utc.subtract(hours=1, minutes=now_utc.minute, seconds=now_utc.second,19 microseconds=now_utc.microsecond)20 class RetryDelay:21 @staticmethod22 def five_minutes():...
DU-Time.py
Source: DU-Time.py
1from datetime import datetime2from pytz import timezone , all_timezones3now_date = datetime(2001,2,3,4,5,6,7)4now_date = datetime.now()5now_utc=now_date.replace(tzinfo=timezone('UTC'))6print('Date:',str(now_date.strftime("%Y-%m-%d %H:%M:%S (%Z) (%z)")))7print('Date:',str(now_utc.strftime("%Y-%m-%d %H:%M:%S (%Z) (%z)")))8print('Year:',str(now_utc.strftime("%Y")))9print('MonthName:',str(now_utc.strftime("%B")))10print('Month:',str(now_utc.strftime("%m")))11print('Day:',str(now_utc.strftime("%d")))12print('Hour:',str(now_utc.strftime("%H")))13print('Minute:',str(now_utc.strftime("%M")))14print('Second:',str(now_utc.strftime("%S")))15print('milliSecond:',str(now_utc.strftime("%f")))16print('weekday:',str(now_utc.strftime("%w")))17print('week of year:',str(now_utc.strftime("%YW%WD%w")))18print('Day of year:',str(now_utc.strftime("%Y/%j")))19print('Zones:',len(all_timezones))20#for zone in all_timezones:...
Check out the latest blogs from LambdaTest on this topic:
The fact is not alien to us anymore that cross browser testing is imperative to enhance your application’s user experience. Enhanced knowledge of popular and highly acclaimed testing frameworks goes a long way in developing a new app. It holds more significance if you are a full-stack developer or expert programmer.
QA testers have a unique role and responsibility to serve the customer. Serving the customer in software testing means protecting customers from application defects, failures, and perceived failures from missing or misunderstood requirements. Testing for known requirements based on documentation or discussion is the core of the testing profession. One unique way QA testers can both differentiate themselves and be innovative occurs when senseshaping is used to improve the application user experience.
Having a good web design can empower business and make your brand stand out. According to a survey by Top Design Firms, 50% of users believe that website design is crucial to an organization’s overall brand. Therefore, businesses should prioritize website design to meet customer expectations and build their brand identity. Your website is the face of your business, so it’s important that it’s updated regularly as per the current web design trends.
Enterprise resource planning (ERP) is a form of business process management software—typically a suite of integrated applications—that assists a company in managing its operations, interpreting data, and automating various back-office processes. The introduction of a new ERP system is analogous to the introduction of a new product into the market. If the product is not handled appropriately, it will fail, resulting in significant losses for the business. Most significantly, the employees’ time, effort, and morale would suffer as a result of the procedure.
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!