使用python实现一个简单的猜数字游戏，
user
```python
import random

def guess_number():
    number_to_guess = random.randint(1, 100)
    attempts = 0
    guessed = False

    print("欢迎参加猜数字游戏！")
    print("我有一个1到100之间的数字，你能猜到它是什么吗？")

    while not guessed:
        try:
            guess = int(input("请输入你的猜测: "))
            attempts += 1

            if guess < number_to_guess:
                print("猜低了！")
            elif guess > number_to_guess:
                print("猜高了！")
            else:
                guessed = True
                print(f"恭喜你！你猜对了，数字是 {number_to_guess}，你用了 {attempts} 次尝试。")
        except ValueError:
            print("请输入一个有效的数字。")

if __name__ == "__main__":
    guess_number()
```
assistant