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}\t{info}\t[{time_str}]".format(phone=sample_phone(),info=sample_info(),time_str=time_str)
        print(query_log)

        f.write(query_log+"\n")
        count = count -1
if __name__ == '__main__':
    generate_log(10)



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

posted @   liuge36  阅读(203)  评论(0编辑  收藏  举报
编辑推荐:
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· .NET Core 中如何实现缓存的预热?
· 三行代码完成国际化适配,妙~啊~
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
点击右上角即可分享
微信分享提示