मैं अजगर का उपयोग कर लिखने कलह बॉट कोशिश कर रहा हूँ के साथ, मैं पार चलो और एक साथ इस बोट फेंक दिया है।अजगर [अमान्य वाक्य रचना] async डीईएफ़
import discord
import asyncio
import random
client = discord.Client()
inEmail = input("Email:")
inPassword = input("Passwd:")
async def background_loop():
await client.wait_until_ready()
while not client.is_closed:
channel = client.get_channel("************")
messages = ["Hello!", "How are you doing?", "Testing!!"]
await client.send_message(channel, random.choice(messages))
await asyncio.sleep(120)
client.loop.create_task(background_loop())
client.run(inEmail, inPassword)
फिर भी जब मैं इसे चलाने के लिए करने की कोशिश की, मैं प्राप्त एक SyntaxError
:
File "1.py", line 7
async def background_loop():
^
SyntaxError: invalid syntax
क्यों है? मैं कभी नहीं मिला है कि इससे पहले कि जब मैं यह परीक्षण किया गया।
'async' का उपयोग करने से पहले एक समारोह परिभाषा अजगर 3.4 या अधिक से अधिक में ही मान्य syntac है। –
हाँ मैं स्क्रिप्ट "python3 1.py" – Andy
मैं देख रहा हूँ का उपयोग कर चल रहे हैं, तो अजगर 3.4 से ऊपर कुछ भी काम करना चाहिए? यह वास्तव में अजीब बात है के बाद से अपने सर्वर अजगर संस्करणों बदल किसी भी तरह रात में: पी – Andy