1, the number of digits in the number of calculations of a document
a = 0 with open("number.txt", "r", encoding="utf8") as f: ret = f.readlines() for item in ret: print(item, type(item)) for i in item: if i.isdigit(): a+=1 print(a)
2, * kwargs use
DEF FUNC (** kwargs): for I in kwargs: # I is a key-value pair for each key obtained Print (I, kwargs [I]) FUNC (OK =. 1, 2 = Yes, = NO. 3 ) # parsing Print ( I) OK Yes NO Print (kwargs) { ' OK ' :. 1, ' Yes ' : 2, ' NO ' :. 3 } { ' OK ' :. 1, ' Yes ' : 2, ' NO ' :. 3 } { 'OK ' :. 1, ' Yes ' : 2, ' NO ' :. 3 } so the result is OK . 1 Yes 2 NO . 3