大家好,一直想写一个控制台,但是一直没成功,请问如何让打印和输入出现在pyqt5的窗口中,或者怎么做输出到控制台之类的事情?
主页
/
user-507326
nise boy's questions
大家好,煎蛋,有这么一个问题,我正在做一个关于赌场的游戏
import random
import time
import os
balance = 555
def game():
game = input('Ваша ставка $ --')
if int(game) > int(balance):
print('Error')
game2 = random.randint(0,5)
game3 = input('Ваше число от 1 до 5 X -- ')
if game3 == game2:
print('Вы вииграли X -- ')
game = int(game) * 2
balance = int(game) + int(balance)
print(str(balance))
else:
print('Проигрыш :(')
balance = int(balance) - int(game)
print(str(balance))
while 1:
cmd = input('X -- ')
if cmd == 'casino':
game()
elif cmd == 'end':
break
但是,当我运行它时,会发生以下错误
Traceback (most recent call last):
File "e:\VSC\pyvsc\hack.py\hacktest.py", line 25, in <module>
game()
File "e:\VSC\pyvsc\hack.py\hacktest.py", line 7, in game
if int(game) > int(balance):
UnboundLocalError: local variable 'balance' referenced before assignment
变量balance
存在,但 def 没有看到它
你好煎蛋卷,我通过os.system('pip install colorama')
它下载模块输出:
Requirement already satisfied: colorama
in c:\users\ilyas\appdata\local\programs\python\python310\lib\site-packages (0.4.4)
WARNING: You are using pip version 22.0.4; however, version 22.1.2 is available.
You should consider upgrading via the 'C:\Users\ilyas\AppData\Local\Programs\Python\Python310\python.exe -m pip install --upgrade pip' command.
我想隐藏它,因为我同时在控制台中显示下载,据我所知,将其称为静默安装是正确的......