流畅的python--第二章 数据结构

#输出ascii码
symbols = '#$%%^&'

codes = []
for symbol in symbols:
    codes.append(ord(symbol))

#筛选
asc = [ord(s) for s in symbols if ord(s) > 57]

#利用map和fiter来进行创建
f_asc = list(filter(lambda c: c>57, map(ord, symbols)))

#元祖拆包
a, b, *rest = range(5)
#当前输出为[2,3,4]

发布了69 篇原创文章 · 获赞 2 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/weixin_42307828/article/details/104079907