最新回答 / 還能學(xué)
for循環(huán)L1分別會(huì)是 [1,2,3]|[5,3,2]|[7,3,2]? ? ? ? ? ? L1[0]? ? ? ? ? ?0 1 2? 0 1 2? ?0 1 2? ? ? ? ? ?每次取L1的0號(hào)元素
2023-12-15
直接使用 get 方法如果找不到默認(rèn)返回 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_慕田峪3431918
python3之前的版本中整型除整型得到的依然是整型,即省略小數(shù),之后的版本整型除整型得到的的是浮點(diǎn)數(shù)
2023-12-12
最新回答 / weixin_慕無忌2350060
?if not isinstance(x,int) or not isinstance(x,float):這里應(yīng)該用and,否則任何類型進(jìn)去都是true
2023-12-12
最新回答 / 慕UI2375754
不需要的,sum相當(dāng)于一個(gè)無限大的容器,sum = sum+x,相當(dāng)于把原本sum容器里的東西加上x再一起返回sum容器里面,sum1=sum+x應(yīng)該理解為把 原本sum容器里的東西加上x放進(jìn)sum1這個(gè)容器
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
最贊回答 / 時(shí)頌望見
元組T = (1, 'CH', [3, 4])內(nèi)的這幾個(gè)元素的類型是不能改變的,[3,4]是T的一個(gè)元素,并且不是元組,所以它的值可變;但是它的類型是不可變的
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