for(i=0; i < data.length; i++){
data = data.replace("plenty",100).replace("some",50).replace("few",20).replace("break",5).replace("null",2).replace("empty",1).replace("undefined",3).replace("NaN",7).replace("undefi","").replace("ned",9)
}
// // remain_stat : none, empty, few, some, plenty
// empty: gray (0–29)/few: red (2–29)/
// some: yellow (30–99 pieces)/plenty: green (100 or more)
I'm a beginner studying Python. We're using public data to spray it on the screen through Python-jango. I'd like to spray it like it's tinned, not just one price for the replace, but I'd like to know how to use the random module.
python django
def makerandom(x):
dic = {'empty':[0,1],'few':[2,29],'some':[30,99],'plenty':[100,100]}
i = dic[x]
a = random.randint(i[0],i[1])
return a
Create a function like this.
data = data.replace("plenty",makerandom("plenty")).replace("some",makerandom("some")).rep.....
I think it's one way to make it into a format.
© 2024 OneMinuteCode. All rights reserved.