简体   繁体   中英

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

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

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")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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