版权声明: https://blog.csdn.net/weixin_38272395/article/details/86101509
import random
print("------猜数字------")
#ans = '8'
ans = random .randint (0,9)
#temp = input("请输入你猜测的数字:")
temp = int(input("请输入你猜测的数字:"))
while 1:
if temp == ans:
print("猜对了 ♪^∀^●ノ")
break
else:
string="猜错了! "
if temp > ans:
string += str(temp)+" 大于目标数字。"
else:
string += str(temp)+" 小于目标数字。"
print(string)
#temp = input("重新输入:")
temp = int(input("重新输入:"))
print("游戏结束!")
字符串:"str" 'str' """长字符串""" 反斜杠( \ )进行字符转义
符号: // 整数除 / 浮点除 ** 阶 and or not
int() str() float()
查看类型:type() isinstance()