摘要:
>>> test1 = ["sss","ccc","aaa","ddd"] >>> test1.reverse() ## 就地反转 >>> test1 ['ddd', 'aaa', 'ccc', 'sss'] >>> test1.reverse() >>> test1 ['sss', 'ccc', 阅读全文
摘要:
>>> test1 = ["ccc","aaa","aaa","ccc","bbb","aaa","ddd","aaa"] >>> test1.count("aaa") 4 >>> for i in range(test1.count("aaa")-1): test1.remove("aaa") > 阅读全文
摘要:
1、求最大值和最小值 >>> test1 = [34,2,5,65,322,21,54] >>> temp = test1[0] >>> for i in test1: if i > temp: temp=i >>> temp 322 >>> for i in test1: if i < temp: 阅读全文
摘要:
1、 + 号拼接 >>> test1 = "abcd" >>> test2 = "opqr" >>> test3 = "xyzh" >>> test1 + test2 'abcdopqr' >>> test2 + test3 'opqrxyzh' >>> test2 + test1 + test3 阅读全文
摘要:
1、format()位置参数 >>> "abcdabdef".format() 'abcdabdef' >>> "abc{0}dabdef".format("YYYY","MMMM","OOOO") 'abcYYYYdabdef' >>> "abc{1}dabdef".format("YYYY"," 阅读全文