Skip to content

Instantly share code, notes, and snippets.

@EdwinTai
Created Sep 15, 2020
Embed
What would you like to do?
python random number usage
import random
def _3d1():#方法一,直接顯示
return print(str(random.randint(0, 9)) + " " + str(random.randint(0, 9)) + " " + str(random.randint(0, 9)))
def _3d2():#方法二,一次抽一顆
result = list()
_3d_ticket = set()
while len(_3d_ticket) < 3:
number = random.randint(0,9)
_3d_ticket.add(number)
for ball in _3d_ticket:
result.append(str(ball))
return print(result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment