为了账号安全,请及时绑定邮箱和手机立即绑定
print('special string:'+"',"+'",'+'\,'+'\\\,'+'\\n,'+'\\t')

最新回答 / 鹿鸣ei
变量不能以数字开头,所以'0''1'……这些数字不能作为变量,改成这样就可以了:template = 'L{a0} i{a1} s{a2},y{a3} n{a4} P{a5}'a0 = 'ife'a1 = 's'a2 = 'hort'a3 = 'ou'a4 = 'eed'a5 = 'ython'result =  template.format(a0 = 'ife' , a1 = 's' , a2 = 'hort' , a3 = 'ou' , a4 = 'eed' , a5 = 'ython')print...
i=0
b=[]
while i<=100:
i=i+1
a=i*i
b.append(a)
print(b)
print(sum(b))
s1 = set([1, 2, 3, 4, 5])
s2 = set([1, 2, 3, 4, 5, 6, 7, 8, 9])
print(s1.isdisjoint(s2))
for s in s1:
if s in s2:
print(s)
L = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
S = set([1, 3, 5, 7, 9, 11])
for l in L:
if l in S:
S.remove(l)
else:
S.add(l)
print(S)
s=set([])
names = ['Jenny', 'Ellena', 'Alice', 'Candy', 'David', 'Hally', 'Bob', 'Isen', 'Karl']
for name in names:
s.add(name)
print(s)
d = {'Alice': [50, 61, 66], 'Bob': [80, 61, 66], 'Candy': [88, 75, 90]}
for key,value in d.items():
print(key)
for a in value:
print(a)
num = 1
product = 1
while num <=10:
product = product * num
num = num + 1
print(product)
s = 'AABCDEFGHHIJ'
result = s[1:9]
print(result)

'''解题思路'''
l = len(s)
print(l) #字符串长度
'''查看字符中每个字母的下标'''
for i in range(0,l):
print(i, s[i])
template = '{0} {1} {2}, {3} {4} {5}'
result = template.format('life', 'is', 'short', 'you', 'need', 'python')

print(result)

template ='{l} {i} {s}, {y} {n} {p}'
l ='life'
i = 'is'
s = 'short'
y = 'you'
n = 'need'
p = 'python'

result = template.format(l=l,i=i,s=s,y=y,n=n,p=p)
print(result)
print("special string: \', \", \\, \\\\, \\n, \\t")
L = ['Alice', 66, 'Bob', True, 'False', 100]
i=0
for item in L:
i=i+1
if i%2==0:
print(item)
s = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
i=0
for k in s:
i=i+1
if i<10:
continue
print(k)
num = 0
sum = 0
while True:
if num > 1000:
break
if num % 2 == 0:
sum = sum + num
num = num + 1
print(sum)
s = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
i=0
for ch in s:
if i>19:
break
i=i+1
print(ch)
sum=1
k=2
while k<=10:
sum=sum*k
k=k+1
print(sum)
课程须知
如果您了解程序设计的基本概念,会简单使用命令行,了解中学数学函数的概念,那么对课程学习会有很大的帮助,让您学起来得心应手,快速进入Python世界。
老师告诉你能学到什么?
通过本课程的学习,您将学会搭建基本的Python开发环境,以函数为基础编写完整的Python代码,熟练掌握Python的基本数据类型以及list和dict的操作,灵活使用流程控制语句。

微信扫码,参与3人拼团

微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号

友情提示:

您好,此课程属于迁移课程,您已购买该课程,无需重复购买,感谢您对慕课网的支持!

本次提问将花费2个积分

你的积分不足,无法发表

为什么扣积分?

本次提问将花费2个积分

继续发表请点击 "确定"

为什么扣积分?

举报

0/150
提交
取消