将多个序列串放在一起遍历:
1
2
3
4
5
6from itertools import chain
1, 2, 3, 4] a = [
'a', 'b', 'c'] b = [
for x in chain(a, b):
print(x)
...python表示昨天的日期:
1
2
3
4
5
6
7
8#-*-coding:utf-8-*-
import datetime
def getYesterday(): #
today=datetime.date.today()
oneday=datetime.timedelta(days=1)
yesterday=today-oneday
return yesterday打印代码出错信息:
1
2import traceback
traceback.format_exc()
traceback.print_exc()跟traceback.format_exc()有什么区别呢?
format_exc()返回字符串,print_exc()则直接给打印出来。