我用Windows 10制作了python代码。它不断重启并且没有显示任何内容。
请帮忙。
这个问题不断发生。我重新启动了ide并尝试使用在线ide。任何可以帮助或解决此问题的信息都会有很大帮助。
import time
global apples
global gold
apples = 0
gold = 0
def start():
print "Hello"
print "My name is Jason"
name = raw_input("What is your Name?")
print "Welcome "+name+"."
print "The object of this game is to pick apples and sell them for gold."
time.sleep(1)
begin = raw_input("Would you like to play?")
print "Y or N"
if begin == "Y":
time.sleep(1)
begin()
if begin == "N":
print "Okay, Please exit the terminal."
print "Goodbye!!!"
def begin():
papple = raw_input("Would you like to Pick some Apples?")
print "Y or N"
if papple == "Y":
time.sleep(1)
apples=apples+5
print "Computer: You picked 5 apples."
print "You now have "+apples+"!!!"
begin()
if papple == "N":
sell = raw_input("Would you like to sell some apples for gold?")
print "Y or N"
if sell == "Y":
time.sleep(1)
gold=gold+5
apples=apples-5
print "Computer: You sold 5 Apples for 5 Gold."
print "You now have "+apples+" apples, and "+gold+" Gold Pieces."
begin()
if sell == "N":
print "Okay"
begin()
答案 0 :(得分:0)
我没有看到任何可以启动功能的东西。尝试添加
<?php
class DB_CONNECT {
function __construct() {
$this->connect();
}
function __destruct() {
$this->close();
}
function connect() {
require_once __DIR__ . '/db_config.php';
$con = mysql_connect(DB_HOST, DB_USER, DB_PASS) or die(mysql_error());
$db = mysql_select_db(DB_NAME) or die(mysql_error());
return $con;
}
function close() {
mysql_close();
}
}
?>
还有很多其他错误。如果您不想通过慢慢调试自己来学习完整代码:
if __name__ == '__main__':
start()
答案 1 :(得分:0)
首先,你没有调用上面定义的任何函数。在main中调用两个函数就像
一样main():
begin()
start()
然后使用
if __name__ == '__main__':main()