I have a list of players with the following attributes - assetId maxBid minPrice maxPrice
How can I create a list in Python and pick one player at random an apply it to a search function.
I am looking to accomplish something like this :
players = []
players.append(13732, 8000, 9300, 9400) #John Terry
players.append(165580, 2400, 3000, 3100) #Diego Alves
for player in players:
items = fut.searchAuctions('player',
assetId=player.assetId,
max_buy=player.maxBid)
I suggest you create a player class:
class Player:
def __init__(self, assetId, maxBid, minPrice, maxPrice):
self.assetId = assetId
self.maxBid = maxBid
self.minPrice = minPrice
self.maxPrice = maxPrice
this way you can create new objects with player = Player(13732, 8000, 9300,9400)
Your list would the be created with
players = []
players.append(Player(13732, 8000, 9300,9400))
players.append(Player(165580, 2400, 3000, 3100))
to select a player randomly you can do
import random
randomPlayer = random.choice(players)
now you can use randomPlayer
and its attributes eg randomPlayer.assetId
and pass it to your search
import random
player = random.choice(players)
player.search()...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.