1Imglist = ['11.jpg','12.jpg','13.jpg','14.jpg','2.jpg','1.jpg',]2 Print(str (imglist))3A = str (imglist). Split (".")4 Print(a)5Ftail =A.pop ()6 Print("-------------------")7 Print(Ftail)8 Print("----$%%%%%%%%---")9 Print(a)Ten One #alist = [123, ' xyz ', ' Zara ', ' abc '] A #print ("A List:", Alist.pop ()) #默认去除最后一个元素, prints out a list:abc - #print ("B List:", Alist.pop (2)) #去除下标为2的元素, prints out b list:zara - #print (alist) #打印出 [123, ' XYZ '] the - #!/usr/bin/python3 - -str ="This is a string EXAMPLE....WOW!!!" + Print(Str.split ()) - Print(Str.split ('I', 1)) + Print(Str.split ('W'))
Prints the result as
D:\software\python\python.exe d:/software/pycharmpython/login/bbb.py['11.jpg','12.jpg','13.jpg','14.jpg','2.jpg','1.jpg']["[' One","jpg ', '","jpg ', '","jpg ', '","jpg ', ' 2","jpg ', ' 1","jpg ']"]-------------------jpg']----$%%%%%%%%---["[' One","jpg ', '","jpg ', '","jpg ', '","jpg ', ' 2","jpg ', ' 1"][' This',' is','string','EXAMPLE....WOW!!!']['th','S is string EXAMPLE....WOW!!!']['This is string example ....','o','!!!']process finished with exit code 0
Usage of pop () and split () in Python