Parsing wxpython、.env Python env无法分析语句
我正在尝试创建一个python程序来嵌入一个Twitch.tv聊天机器人,当聊天中说了某些事情或某个事件(新订户、关注者等)完成时,它将播放一个预先制作的视频。 我确实有一些问题,但我会提到迄今为止最大的问题。我把秘密信息藏起来了。编码器程序=升华3 由于主文件中有引号,因此主文件中的引号有时会失败。很抱歉 运行时,我得到以下输出:Parsing wxpython、.env Python env无法分析语句,parsing,wxpython,dotenv,Parsing,Wxpython,Dotenv,我正在尝试创建一个python程序来嵌入一个Twitch.tv聊天机器人,当聊天中说了某些事情或某个事件(新订户、关注者等)完成时,它将播放一个预先制作的视频。 我确实有一些问题,但我会提到迄今为止最大的问题。我把秘密信息藏起来了。编码器程序=升华3 由于主文件中有引号,因此主文件中的引号有时会失败。很抱歉 运行时,我得到以下输出: Python-dotenv could not parse statement starting at line 1 Python-dotenv could not
Python-dotenv could not parse statement starting at line 1
Python-dotenv could not parse statement starting at line 2
Python-dotenv could not parse statement starting at line 3
Python-dotenv could not parse statement starting at line 4
Traceback (most recent call last):
File "frame1.py", line 149, in <module>
main()
我的主代码文件:
#frame1.py
导入wx,wx.media
导入操作系统
从twitchio.ext导入命令
从dotenv导入加载\u dotenv
加载_dotenv()
类FrameClass(wx.Frame):
definit(自身、父项):
超级(FrameClass,self)。init(父级,title=“超级机器人”,大小=(750400))
类LeftPanel(wx.Panel):
definit(自身、父项):
wx.Panel.init(self,parent=parent)
类右面板(wx.Panel):
definit(自身、父项):
wx.Panel.init(self,parent=parent)
类ChatBot(commands.Bot):
def初始化(自身):
super()
def main():
App=wx.App()
框架类(无)
App.MainLoop()
main()在
.env
file@RolfofSaxonythank你是如此之多,如此之小,以至于眼睛可以如此轻易地跳过。总是这些小东西让你停滞不前,让你灰心丧气。:)
#frame1.py
irc_token = os.environ['TMI_TOKEN']
client_id = os.environ['CLIENT_ID']
nick = os.environ['BOT_NICK']
prefic = os.environ['BOT_PREFIX']
initial_channels = os.environ['CHANNEL']
menuBar = wx.MenuBar()
fileMenu = wx.Menu()
connectMenu = wx.Menu()
helpMenu = wx.Menu()
openItem = fileMenu.Append(wx.ID_OPEN, 'Open')
saveItem = fileMenu.Append(wx.ID_SAVE, 'Save As')
exitItem = fileMenu.Append(wx.ID_EXIT, 'EXIT')
helpItem = helpMenu.Append(wx.ID_HELP, 'Help!')
menuBar.Append(fileMenu, '&File')
menuBar.Append(connectMenu, '&Connect')
menuBar.Append(helpMenu, '&About')
self.Bind(wx.EVT_MENU, self.OnOpen, openItem)
self.Bind(wx.EVT_MENU, self.SaveAs, saveItem)
self.Bind(wx.EVT_MENU, self.Quit, exitItem)
self.Bind(wx.EVT_MENU, self.OnHelp, helpItem)
self.SetMenuBar(menuBar)
self.CreateStatusBar()
self.SetStatusText("Welcome to the new Bot!")
vsplitter = wx.SplitterWindow(self)
left = LeftPanel(vsplitter)
right = RightPanel(vsplitter)
vsplitter.SplitVertically(left, right)
vsplitter.SetMinimumPaneSize(200)
bot = ChatBot()
self.Show(True)
def OnOpen(self, event):
with wx.FileDialog(self, "Open XYZ file", wildcard="XYZ files (*.xyz)|*.xyz", style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST) as fileDialog:
if fileDialog.ShowModal() == wx.ID_CANCEL:
return
pathname = fileDialog.GetPath()
try:
with open(pathname, 'r') as file:
self.doLoadDataOrWhatever(file)
except IOError:
wx.LogError("Cannot open file '%s'." % newfile)
def SaveAs(self, event):
with wx.FileDialog(self, "Save XYZ file", wildcard="XYZ files (*.xyz)|*.xyz", style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT) as fileDialog:
if fileDialog.ShowModal() == wx.ID_CANCEL:
return # the user changed their mind
# save the current contents in the file
pathname = fileDialog.GetPath()
try:
with open(pathname, 'w') as file:
self.doSaveData(file)
except IOError:
wx.LogError("Cannot save current data in file '%s'." % pathname)
def Quit(self, e):
self.Close()
def OnHelp(self, e):
"""Display an help Dialog"""
wx.MessageBox("This is where future help will be placed. Dont Forget!", "Help", wx.OK|wx.ICON_INFORMATION)
wx.Button(self, -1, "Test Idle", pos = (10, 10))
self.SetBackgroundColour("grey")
self.testMedia = wx.media.MediaCtrl(self, style=wx.SIMPLE_BORDER, szBackend = wx.media.MEDIABACKEND_WMP10)
self.media = 'C:\\Wiggle_Bot\\Python (Offline)\\JustDoIt.mp4'
self.testMedia.Bind(wx.media.EVT_MEDIA_LOADED, self.play)
self.testMedia.SetVolume(0.5)
if self.testMedia.Load(self.media):
pass
else:
print("Media not found")
self.quit(None)
def play(self, event):
self.testMedia.Play()
# Events don't need decorators when subclassed
async def event_ready(self):
print(f'Ready | {self.nick}')
async def event_message(self, message):
print(message.content)
await self.handle_commands(message)
# Commands use a decorator...
@commands.command(name='test')
async def my_command(self, ctx):
await ctx.send(f'Hello {ctx.author.name}!')