📜  跟踪表python代码示例

📅  最后修改于: 2022-03-11 14:45:47.806000             🧑  作者: Mango

代码示例2
var = '  this   is a test   '
 
word_counter = 0
 
start_status = True
 
for i in range(len(var)):
 
  if var[i] != ' ':
 
    if start_status == True:
 
      word_counter = word_counter + 1
 
      start_status = False
 
  if var[i]==' ':
 
    start_status = True
 print(word_counter)