Untitled
unknown
plain_text
a year ago
573 B
4
Indexable
Never
# Online Python compiler (interpreter) to run Python online. # Write Python 3 code in this online editor and run it. import numpy as np import numpy.random as rnd array = rnd.randint(2,size=100) d = array.astype(str) print(d) print('###Method1###') d[d=='0']='F' ###代表從d陣列中選出d=0的index d[d=='1']='M' print(d) print('###Method2###') danother = array.astype(str) for i in range(len(danother)): if (danother[i]=='0'): danother[i]='F' ##從danother找出若為0則取代為F else: danother[i]='M' print(danother) print(len(danother))