摘要: >>> numb=list(range(1,6))>>> print(numb)[1, 2, 3, 4, 5] >>> digits=list(range(1,6))>>> min(digits)1>>> max(digits)5>>> sum(digits)15 >>> squares = lis 阅读全文
posted @ 2020-01-08 17:55 flyme2moon 阅读(127) 评论(0) 推荐(0)
摘要: >>> string=' python '>>> string' python '>>> string.rstrip()' python' >>> string.rstrip()' python'>>> string.strip()'python'>>> string.lstrip()'python 阅读全文
posted @ 2020-01-07 14:19 flyme2moon 阅读(108) 评论(0) 推荐(0)
摘要: 首先说一下format函数,用{}和:代替了%,比如: >>>“{} {} {}”.format("I","LOVE","STUDY") >>>'I LOVE STUDY'>>>"{0} {1} {0}".format("hi","hello")>>>'hi hello hi' 还有: >>>nam 阅读全文
posted @ 2019-12-12 14:03 flyme2moon 阅读(992) 评论(0) 推荐(0)
摘要: 1 string="hello" 2 3 #%s打印时结果是hello 4 print "string=%s" % string # output: string=hello 5 6 #%2s意思是字符串长度为2,当原字符串的长度超过2时,按原长度打印,所以%2s的打印结果还是hello 7 pri 阅读全文
posted @ 2019-12-12 13:59 flyme2moon 阅读(436) 评论(0) 推荐(0)