python list 簡寫

  • 190
  • 0

python list 簡寫

        #寫法一:
        rows3=[]
        for i in range(0, len(rows)):
            rows3.append(WordChange(rows[i]))
        print(rows3)
        
        print('\n')

        #寫法2:
        rows = [WordChange(str(rows[i])) for i in range(0, len(rows))]
        print(rows)
        
...繼續閱讀 »