>>> s='AABCDEFGHHIJ'
>>> abcdefgh=s[1:9]
>>> print(abcdefgh)
ABCDEFGH
>>> abcdefgh=s[1:9]
>>> print(abcdefgh)
ABCDEFGH
2021-01-07
>>> s1='這是一句中英文混合的Python字符串:Hello World!'
>>> print(s1)
這是一句中英文混合的Python字符串:Hello World!
>>> print(s1)
這是一句中英文混合的Python字符串:Hello World!
2021-01-07
T = ((1+2), ((1+2),), ('a'+'b'), (1, ), (1,2,3,4,5))
for a in T:
print(type(a))
結(jié)果:
<class 'int'>
<class 'tuple'>
<class 'str'>
<class 'tuple'>
<class 'tuple'>
所以是3個
for a in T:
print(type(a))
結(jié)果:
<class 'int'>
<class 'tuple'>
<class 'str'>
<class 'tuple'>
<class 'tuple'>
所以是3個
2021-01-07
>>> template='Life is short,you need {}'
>>> a='Python'
>>> result=template.format(a)
>>> print(result)
Life is short,you need Python
或者
>>> template='Life is short,{}'
>>> a='you need Python'
>>> result=template.format(a)
>>> print(result)
Life is short,you need Python
>>> a='Python'
>>> result=template.format(a)
>>> print(result)
Life is short,you need Python
或者
>>> template='Life is short,{}'
>>> a='you need Python'
>>> result=template.format(a)
>>> print(result)
Life is short,you need Python
2021-01-07
>>> template='Life is short,you need {}'
>>> a='Python'
>>> result=template.format(a)
>>> print(result)
Life is short,you need Python
或者
>>> template='Life is short,{}'
>>> a='you need Python'
>>> result=template.format(a)
>>> print(result)
Life is short,you need Python
>>> a='Python'
>>> result=template.format(a)
>>> print(result)
Life is short,you need Python
或者
>>> template='Life is short,{}'
>>> a='you need Python'
>>> result=template.format(a)
>>> print(result)
Life is short,you need Python
2021-01-07
可以參考一下我的:
num=0
sum=0
while num<=1000:
if num%2<>0:
num=num+1
continue
sum=sum+num
num=num+1
print(sum,num)
num=0
sum=0
while num<=1000:
if num%2<>0:
num=num+1
continue
sum=sum+num
num=num+1
print(sum,num)
2021-01-06
d = {
'Alice': [45],
'Bob': [60],
'Candy': [75],
};
socre_a=[50,61,66];
socre_b=[80,61,66];
socre_c=[88,75,90];
num=0;
while num<3:
d['Alice'].append(socre_a[num]);
d['Bob'].append(socre_b[num]);
d['Candy'].append(socre_c[num]);
num+=1;
print(d);
'Alice': [45],
'Bob': [60],
'Candy': [75],
};
socre_a=[50,61,66];
socre_b=[80,61,66];
socre_c=[88,75,90];
num=0;
while num<3:
d['Alice'].append(socre_a[num]);
d['Bob'].append(socre_b[num]);
d['Candy'].append(socre_c[num]);
num+=1;
print(d);
2021-01-06
>>> s='special string:\',",\\,\\\,\\n,\\t'
>>> print(s)
special string:',",\,\\,\n,\t
>>> print(s)
special string:',",\,\\,\n,\t
2021-01-05
#coding:UTF-8
num = 1
a=0
sum=0
while True:
if a>1000:
break
if a%2==1:
sum=sum+0
else:
sum=sum+a
a=a+2
print(sum)
num = 1
a=0
sum=0
while True:
if a>1000:
break
if a%2==1:
sum=sum+0
else:
sum=sum+a
a=a+2
print(sum)
2021-01-05
>>> num=3.14*1.57
>>> print(num)
4.9298
>>> round(num,2)
4.93
我就這樣寫的
>>> print(num)
4.9298
>>> round(num,2)
4.93
我就這樣寫的
2021-01-05
template='Life is short,you need {}'
python='python'
result=template.format(python)
print(result)
python='python'
result=template.format(python)
print(result)
2021-01-01
# coding: utf-8
score = 95
if score < 60:
print('抱歉,考試不及格')
elif score >= 90:
print('恭喜你,拿到卓越的成績')
elif score >= 80:
print('恭喜你,拿到優(yōu)秀的成績')
else:
print('恭喜你,考試及格')
score = 95
if score < 60:
print('抱歉,考試不及格')
elif score >= 90:
print('恭喜你,拿到卓越的成績')
elif score >= 80:
print('恭喜你,拿到優(yōu)秀的成績')
else:
print('恭喜你,考試及格')
2020-12-31