Linux使用命令行cmd运行多个python文件

假如为的文件夹下有三个文件:

testm.py为主函数,testi.py为子函数提供功能,groundtruth.txt存的数据。

文件:链接: https://pan.baidu.com/s/1_Yh2iiHexOaIcb_sQGiYgA 提取码: n27r

三模块内容如下:

testm.py

import testi

def main():                         # first train then restart your program and test
    testi.testii()
                 

if __name__ == '__main__':
    main()

testi.py

import numpy as np
import matplotlib.pyplot as plt
import mpl_toolkits.mplot3d
def testii():
    f = open("./groundtruth.txt")
    x = []
    y = []
    z = []
    for line in f:
        if line[0] == '#':
            continue
        data = line.split()
        x.append( float(data[1] ) )
        y.append( float(data[2] ) )
        z.append( float(data[3] ) )
    ax = plt.subplot( 111, projection='3d')
    ax.plot(x,y,z)
    plt.show()

groundtruth.txt

1305031449.7996 1.2334 -0.0113 1.6941 0.7907 0.4393 -0.1770 -0.3879
1305031449.8096 1.2334 -0.0111 1.6939 0.7911 0.4393 -0.1768 -0.3872
1305031449.8196 1.2330 -0.0111 1.6937 0.7913 0.4387 -0.1769 -0.3873
1305031449.8295 1.2328 -0.0110 1.6936 0.7916 0.4384 -0.1768 -0.3872
1305031449.8396 1.2325 -0.0110 1.6934 0.7919 0.4380 -0.1768 -0.3871
1305031449.8495 1.2323 -0.0110 1.6934 0.7923 0.4379 -0.1760 -0.3866
1305031449.8595 1.2321 -0.0109 1.6932 0.7925 0.4374 -0.1758 -0.3868
1305031449.8696 1.2316 -0.0108 1.6929 0.7926 0.4370 -0.1758 -0.3871
1305031449.8795 1.2312 -0.0108 1.6927 0.7929 0.4368 -0.1755 -0.3869
1305031449.8896 1.2307 -0.0106 1.6924 0.7932 0.4368 -0.1750 -0.3865
1305031449.8994 1.2302 -0.0105 1.6922 0.7935 0.4366 -0.1745 -0.3863
1305031449.9095 1.2298 -0.0105 1.6920 0.7936 0.4368 -0.1739 -0.3861
1305031449.9195 1.2292 -0.0104 1.6917 0.7935 0.4368 -0.1735 -0.3865
1305031449.9295 1.2286 -0.0103 1.6915 0.7934 0.4369 -0.1732 -0.3869
1305031449.9395 1.2279 -0.0102 1.6914 0.7929 0.4370 -0.1733 -0.3876
1305031449.9496 1.2273 -0.0101 1.6913 0.7925 0.4372 -0.1733 -0.3883
1305031449.9595 1.2268 -0.0099 1.6912 0.7921 0.4374 -0.1735 -0.3886

在你有对应库的情况下使用命令行,即可使用testm调用testi里的testii函数

安装:

sudo apt-get install python-matplotlib python-numpy

使用:

python testm.py

效果:

 

 

 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值