简体   繁体   English

执行 Python 脚本时没有结果

[英]no results when executing Python Script

Im new to python and trying to have this python script to create a very simple custom topology in mininet in an Ubuntu live server However, when I enter "sudo Python SDN.py" it gives no result whatsoever我是 python 新手,并试图让这个 python 脚本在 Ubuntu 实时服务器的 mininet 中创建一个非常简单的自定义拓扑但是,当我输入“sudo Python SDN.py”时,它没有任何结果

from mininet.topo import Topo  
class MyTopo( Topo ):  
    "Simple topology example."
    def __init__( self ):
        "Create custom topo."

        # Initialize topology
        Topo.__init__( self )

        # Add hosts and switches
        hostx = self.addHost( 'h1' )
        Sw1 = self.addSwitch('s1')

        # Add links
        self.addLink( Hostx, Sw1 )
        topos = { 'mytopo': ( lambda: MyTopo() ) }

any help is welcome, please note i'm only day 2 into python欢迎提供任何帮助,请注意我只是 Python 的第 2 天

You're never actually running anything!你从来没有真正运行过任何东西! Take this for example:以这个为例:

def func(a):
    print(a)

This snippet won't do anything unless you actually make a call to the function, like this:除非您实际调用该函数,否则此代码段不会执行任何操作,如下所示:

func("test")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM