st = '!@#$%^&*'
codes = []
for s in st:
codes.append(ord(s))
print(codes)
[33, 64, 35, 36, 37, 94, 38, 42]
st = '!@#$%^&*'
codes = [ord(s) for s in st]
priont(codes)
[33, 64, 35, 36, 37, 94, 38, 42]
colors = ['blacks', 'white']
sizes = ['s', 'M', 'L']
for tshirt in ('%s %s'%(c, s) for c in colors for s in sizes):
print(tshirt)
blacks s
blacks M
blacks L
white s
white M
white L
import itertools
print(list(itertools.product(['blacks', 'white'], ['S', 'M', 'L'])))
[('blacks', 'S'), ('blacks', 'M'), ('blacks', 'L'), ('white', 'S'), ('white', 'M'), ('white', 'L')]
player_infos = [('kobe', '24'), ('james', '23'), ('Iverson', '3')]
for player_names, _ in player_infos:
print(player_names)
kobe
james
Iverson
a, b, *c = range(8)
print(a, b, c)
0 1 [2, 3, 4, 5, 6, 7]
a, *b, c, d = range(5)
print(a,b,c,d)
0 [1, 2] 3 4
*a, b, c, d = range(5)
print(a,b,c,d)
[0, 1] 2 3 4
s = 'basketball'
print(s[::-1])
llabteksab
l = [1, 2, 3]
print(id(l))
17159400
l = [1, 2, 3]
print(id(l))
28562664
l *= 2
print(l)
[1, 2, 3, 1, 2, 3]
print(id(l))
28562664
t = (1, 2, 3)
print(id(t))
54827560
t *= 2
print(t)
(1, 2, 3, 1, 2, 3)
print(id(t))
54752040
t = (1, 2, [30, 40])
t[2] += [50, 60]
print(t)
(1, 2, [30, 40, 50, 60])
人生漫漫其修远兮,网安无止境。
一同前行,加油!