通过参考网络搜索的资料,发现字符串的format()方法的使用有点错误。
修改如下:
参考链接:
person=['zhangsan','lisi','noboday']
person.append('wangwu')
print(person)
# https://www.runoob.com/python/att-string-format.html
# https://zhuanlan.zhihu.com/p/151442933
# https://zhuanlan.zhihu.com/p/424862897
a= "My best friend is {}.".format(person[3].title())
print(a)
person[0]='zhaoliu'
person[1]='dingqi'
del person[2]
person[2]='huba'
person.append('xuejiu')
person.append('yuanshi')
b="My best friend is {}.".format(person[2])
print(person)
print(b)
第一个问题:将format改为f
第二个问题:所有的标点符号都要在英文状态下输入。
如果觉得有用,请采纳一下,非常感谢!
try:
<语句>
except <异常名1>:
print('异常说明1')
except <异常名2>:
print('异常说明2')
else:
<语句> # try语句中没有异常则执行此段代码