小编Cap*_*tay的帖子

从另一个文件中的类导入函数?

我正在编写一个有趣的Python程序但是试图从另一个文件中的类导入函数时遇到困难.这是我的代码:

#jurassic park mainframe

from random import randint
from sys import exit
from comm_system import Comm_system #the file i want to import from



class Jpark_mainframe(object):
    def mainframe_home(self):
        print "=====Welcome to the Jurassic Park Mainframe====="
        print "==========Security Administration==============="
        print "===========Communications Systems==============="
        print "===============System Settings=================="
        print "===================Quit========================="

        prompt = raw_input("What would you like to do? ")

        while prompt != "Quit":

            if prompt == "Security Administration":
                print "Please enter the 5-digit passcode:"
                security_passcode = "%d%d%d%d%d" % (2, 0, 1, 2, randint(1, 2))
                security_guess …
Run Code Online (Sandbox Code Playgroud)

python import class

58
推荐指数
2
解决办法
22万
查看次数

比较双打

我正在编写一个由while循环组成的程序,它读取两个双打并打印它们.该程序还会打印较大的数字和较小的数字.

这是我到目前为止的代码.

int main()
{

                                    // VARIABLE DECLARATIONS 

    double a;
    double b;

    while (a,b != '|')              //WHILE A & B DO NOT EQUAL '|'
    {
        cin >>a >>b;
        cout << a << b << "\n" ;


        if (a<b)                    //IF A<B: SMALLER VALUE IS A
        cout << "The smaller value is:" << a << endl 
             << "The larger value is:" << b << endl ;

        else if (b<a)               //ELSE IF B<A 
            cout << "The smaller value is:" << b << endl …
Run Code Online (Sandbox Code Playgroud)

c++

11
推荐指数
2
解决办法
2万
查看次数

标签 统计

c++ ×1

class ×1

import ×1

python ×1