(1) How to import a user's defined module 't1.py' in 't.py' ?
@t1.py
def watchout():
print "Did you call me?"
@t.py
#! python2
import t1
t1.watchout()
=========Output===========
> t.py
Did you call me?
==========================
(2) Popen, same as C++
@c.cpp, compile it to c.exe
#include <stdio.h>
int main()
{
printf("Hi Martin\nHi Megan\n");
return 0;
}
@p.py
#! python2
import os
output = os.popen('c.exe')
print output.read()
=========Output===========
> p.py
Hi Martin
Hi Megan
==========================
沒有留言:
張貼留言