python常用表达式
enumerate
(iterable, start=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是一种最常见的二进制编码方法。