What are the relevant memos of Python
What are the relevant memos of Python? in view of this question, this article introduces in detail the corresponding analysis and answers, hoping to help more partners who want to solve this problem to find a more simple and feasible way.
Python related memo:
Convert UTC time to standard time with TZ format:
Now_time = datetime.datetime.utcnow () + datetime.timedelta (hours=8) now_time.strftime ('% Ymuri% MMMI% DT% HGV% MGV% S.F% z')
two。 Get current and seven days ago UTC format timestamps
Import datetimelast_7day=datetime.datetime.utcnow ()-datetime.timedelta (days=6, hours=16) now_time=datetime.datetime.utcnow () + datetime.timedelta (hours=8) last_7day=last_7day.strftime ('% Ymuri% MMI% DT% HGV% MV% S.F% Z') now_time=now_time.strftime ('% YMMI% MMI% DT% HGV% MGV% S.% f% z')
3. Convert datetime to UNIX timestamp
Import timeimport datetimedtime = datetime.datetime.now () ans_time = time.mktime (dtime.timetuple ()) print (int (ans_time)) # second timestamp print (int (round (ans_time * 1000)) # millisecond timestamp print (int (round (ans_time * 1000000) # microsecond timestamp what are the answers to the questions about Python's memo? I hope the above content can help you to a certain extent, if you still have a lot of doubts to be solved, you can follow the industry information channel to learn more related knowledge.