第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

如何在交互式shell中使用腳本

如何在交互式shell中使用腳本

慕妹3242003 2021-03-17 13:09:51
我寫了下面的python程序#! /usr/bin/pythondef checkIndex(key):    if not isinstance(key, (int, long)): raise TypeError    if key<0: raise IndexErrorclass ArithmeticSequence:    def __init__(self, start=0, step=1):        self.start = start      # Store the start value        self.step = step        # Store the step value        self.changed = {}       # No items have been modified    def __getitem__(self, key):        checkIndex(key)        try: return self.changed[key]        except KeyError:            return self.start + key*self.step    def __setitem__(self, key, value):        checkIndex(key)        self.changed[key] = value我做的時(shí)候程序是my.pychmod +x my.pypython my.py在執(zhí)行完此步驟后,我將回到bash shelluser@ubuntu:~/python/$ pythonPython 2.7.3 (default, Aug  1 2012, 05:14:39) [GCC 4.6.3] on linux2Type "help", "copyright", "credits" or "license" for more information.>>> s=ArithmeticSequence(1,2)Traceback (most recent call last):  File "<stdin>", line 1, in <module>NameError: name 'ArithmeticSequence' is not defined我如何給程序輸入并運(yùn)行它,因?yàn)樗驯4嬖趘i中
查看完整描述

3 回答

?
拉丁的傳說(shuō)

TA貢獻(xiàn)1789條經(jīng)驗(yàn) 獲得超8個(gè)贊

好吧,您要么必須使用以下程序作為程序來(lái)運(yùn)行它


if __name__ == 'main':

    # Your code goes here. This will run when called from command line.

或者,如果您在python解釋器中,則必須使用以下命令導(dǎo)入“ my”:


>>> import my


查看完整回答
反對(duì) 回復(fù) 2021-03-30
  • 3 回答
  • 0 關(guān)注
  • 135 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)