python常用表达式

enumerate(iterablestart=0)

seasons = ['Spring', 'Summer', 'Fall', 'Winter'] list(enumerate(seasons)) [(0, 'Spring'), (1, 'Summer'), (2, 'Fall'), (3, 'Winter')] list(enumerate(seasons, start=1)) [(1, 'Spring'), (2, 'Summer'), (3, 'Fall'), (4, 'Winter')]

Equivalent to:

def enumerate(sequence, start=0):
    n = start
    for elem in sequence:
        yield n, elem
        n += 1

 

获取当前日期和时间

from datetime import datetime
>>> now = datetime.now() # 获取当前datetime
>>> print(now)
2015-05-18 16:28:07.198690
>>> print(type(now))
<class 'datetime.datetime'>

Base64是一种用64个字符来表示任意二进制数据的方法。Base64是一种最常见的二进制编码方法。

posted @ 2021-09-10 10:20  你的小可爱正在赶来  阅读(51)  评论(0编辑  收藏  举报