findall()
Import Re "" " " D "represents taking figures 0-9, " D "indicates not digital, " W "in a regular inside when the match from lowercase a through z, uppercase A to Z, numerals 0 to. 9 " W is "in a regular in addition to which the representative matching alphanumeric special symbol "" " S = ' one1two2three3four4five12345 ' K = the re.compile ( ' \ + D ' ) # '\ + D' equivalent '\ D \ D \ D' # findAll () function three representation Print (k.findall (S)) Print (the re.findall (K, S)) Print (the re.findall ( ' \ D + ' , S))
jsonpath()
Import Requests, jsonpath Shop = requests.get (url = "" ) .json () # shop All books author_list = jsonpath.jsonpath (Shop, ' $ .store.book [*]. author ' ) # returns all the author author_list2 = jsonpath.jsonpath (Shop, ' $ .. author ' ) # store everything category_dx = jsonpath.jsonpath (Shop, ' $ .store. * ' ) # stores all price store_price_list = jsonpath.jsonpath (Shop, ' $ .store..price ' ) # The third book book_3 = jsonpath.jsonpath (Shop, 'Book .. $ [2] ' ) # last book book_last = jsonpath.jsonpath (Shop, ' $ .. Book [-1] ' ) NUM = len (jsonpath.jsonpath (Shop, ' $ .. Book ' ) ) -1 book_last = jsonpath.jsonpath (Shop, F ' $ .. book [{NUM}] ' ) # value # first two books book_12 = jsonpath.jsonpath (Shop, F ' $ .. book [0,1 ] ' ) # filter all cheaper than 10 books book_lg10 = jsonpath.jsonpath (Shop, ' $ .. book [? (@.. price <10)] ' ) # use to filter all books isbn number book_lg10=jsonpath.jsonpath(shop,'$..book[?(@.isbn)]')