我正在尝试写一个乐透程序

时间:2016-10-31 18:07:25

标签: python

我正在尝试编写一个简单的假乐透程序(只是为了和我的朋友一起玩,并且还给我更多的编程练习)

我不断收到错误SyntaxError: invalid token with an arrow pointing at the number 2 in 02

我现在只有2行,因为我喜欢经常检查我的工作,因为我正在使用" print"陈述以显示随机区域的进展情况。这就是我到目前为止所做的一切:

#numbers for fake lotto
lotto = (02 03 16 48 56 01 28 33 55 56 10 16 38 43 63 23 49 57 64 67 16 30)

print(lotto)

1 个答案:

答案 0 :(得分:1)

您的代码中应该纠正两个错误

  • 列表需要 xcode-select: command not found ip-10-4-89-242 ~ $ gcc gcc: fatal error: no input files compilation terminated. ip-10-4-89-242 ~ $ xcode-select --install xcode-select: command not found 来分隔元素
  • 以0开头的数字不会被视为基数10,正如您所期望的那样。以零开头的数字表示带有,前缀的十六进制数字。例如,0x表示为30x3表示为15,带有十六进制表示法。计算表示与字符串表示不同:您可以使用0xF前缀打印30

你应该试试

'{0:02d}'.format(3)