首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我想不一致的机器人写另一个python脚本输出与命令

我想不一致的机器人写另一个python脚本输出与命令
EN

Stack Overflow用户
提问于 2020-09-01 20:14:08
回答 1查看 184关注 0票数 0

我确实构建了一个不和谐的机器人,我想添加一个命令来运行和读取python中的另一个脚本输出,我该如何做呢?这是我关于不一致的新机器人

代码语言:javascript
复制
import discord
from discord.ext import commands, tasks

import discord
from discord.ext import commands, tasks
from itertools import cycle

flashing = commands.Bot(command_prefix='.')

@flashing.command()

async def ping(ctx):
    await ctx.send(f'Pong! {round(flashing.latency * 1000)} ms' )
    print('bot is ready.')

@flashing.event
async def on_ready():
    change_status.start()


flashing.run('token')

另一个脚本名称为base_script.py

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-09-01 20:34:20

假设这两个脚本位于同一文件夹中:

代码语言:javascript
复制
#scripts.py
def Some_Code():
    #Put all of scripts.py code in this function
    return(Variables)
    #make sure to return all variable that you want to read in your other file

假设您已经这样设置了scripts.py,剩下的就很简单了:

代码语言:javascript
复制
import scripts
print(scripts.Some_Code())
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63687442

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档