zoukankan      html  css  js  c++  java
  • Python模拟产生实时信令

    模拟信令的生成

    import random
    import time
    import os
    
    infos = [
            "116.191031,39.988585",
            "116.389275,39.925818",
            "116.287444,39.810742",
            "116.481707,39.940089",
            "116.410588,39.880172",
            "116.394816,39.91181",
            "116.416002,39.952917"
    ]
    
    phones = [
        "13888888888","13877777777","13866666666",
        "15788888888","15777777777","15766666666",
        "18288888888","18277777777","18266666666"
    ]
    
    def sample_phone():
        return random.sample(phones,1)[0]
    
    def sample_info():
        return random.sample(infos,1)[0]
    
    def generate_log(count=5):
        time_str = time.strftime("%Y-%m-%d %H:%M:%S",time.localtime())
        f = open(os.path.dirname(os.path.realpath(__file__))+"/auto.log","a+")
        while count >=1:
            query_log = "{phone}	{info}	[{time_str}]".format(phone=sample_phone(),info=sample_info(),time_str=time_str)
            print(query_log)
    
            f.write(query_log+"
    ")
            count = count -1
    if __name__ == '__main__':
        generate_log(10)
    
    
    
    

    在上linux的定时执行任务就能实现,信令的实时模拟。

  • 相关阅读:
    blktrace 梁斌说
    线索二叉树
    Boost库中文文档
    STL中的equal函数
    HDU3661_assignments_活动分配_贪心
    转:数据结构小结
    HDU2273_车通过路口
    C++之lexicographical_compare
    HDU1671_Phone List
    HDU2277_变色球
  • 原文地址:https://www.cnblogs.com/liuge36/p/12614773.html
Copyright © 2011-2022 走看看