最新回答 / 還能學
for循環L1分別會是 [1,2,3]|[5,3,2]|[7,3,2]? ? ? ? ? ? L1[0]? ? ? ? ? ?0 1 2? 0 1 2? ?0 1 2? ? ? ? ? ?每次取L1的0號元素
2023-12-15
直接使用 get 方法如果找不到默認返回 None 的特性,代碼如下。
d = {
'Alice': 45,
'Bob': 60,
'Candy': 75,
'David': 86,
'Ellena': 49
}
names = ["Alice", "Bob", "Candy", "Mimi", "David"]
for name in names :
print(d.get(name))
d = {
'Alice': 45,
'Bob': 60,
'Candy': 75,
'David': 86,
'Ellena': 49
}
names = ["Alice", "Bob", "Candy", "Mimi", "David"]
for name in names :
print(d.get(name))
2023-12-13
最新回答 / weixin_慕無忌2350060
?if not isinstance(x,int) or not isinstance(x,float):這里應該用and,否則任何類型進去都是true
2023-12-12
最新回答 / 慕UI2375754
不需要的,sum相當于一個無限大的容器,sum = sum+x,相當于把原本sum容器里的東西加上x再一起返回sum容器里面,sum1=sum+x應該理解為把 原本sum容器里的東西加上x放進sum1這個容器
2023-12-08
print(r'''"To be, or not to be": that is the question.
Whether it's nobler in the mind to suffer.''')
Whether it's nobler in the mind to suffer.''')
2023-12-07
最贊回答 / 時頌望見
元組T = (1, 'CH', [3, 4])內的這幾個元素的類型是不能改變的,[3,4]是T的一個元素,并且不是元組,所以它的值可變;但是它的類型是不可變的
2023-12-04
方式1:
template='life {0}, {1} Python.'
a='is short'
b='you need'
result=template.format(a,b)
print(result)
方式2:
template='life {o}, {t} Python.'
one='is short'
two='you need'
result=template.format(o=one,t=two)
print(result)
template='life {0}, {1} Python.'
a='is short'
b='you need'
result=template.format(a,b)
print(result)
方式2:
template='life {o}, {t} Python.'
one='is short'
two='you need'
result=template.format(o=one,t=two)
print(result)
2023-11-30