SORU
16 EYLÜL 2008, Salı


Bir Python komut dosyası kullanarak mesaj göndermek

Bir şekilde bir Python komut dosyasını kullanarak bir mesaj göndermek için var mı?

CEVAP
19 NİSAN 2012, PERŞEMBE


http://docs.python-requests.org/en/latest/user/quickstart/#post-a-multipart-encoded-file

İstekleri çok basit Parçalı kodlanmış dosya yüklemek için yapar:

>>> r = requests.post('http://httpbin.org/post', files={'report.xls': open('report.xls', 'rb')})

İşte bu kadar. Şaka - bu kod satırı değilim. Dosya gönderildi. Kontrol edelim:

>>> r.text
{
  "origin": "179.13.100.4",
  "files": {
    "report.xls": "<censored...binary...data>"
  },
  "form": {},
  "url": "http://httpbin.org/post",
  "args": {},
  "headers": {
    "Content-Length": "3196",
    "Accept-Encoding": "identity, deflate, compress, gzip",
    "Accept": "*/*",
    "User-Agent": "python-requests/0.8.0",
    "Host": "httpbin.org:80",
    "Content-Type": "multipart/form-data; boundary=127.0.0.1.502.21746.1321131593.786.1"
  },
  "data": ""
}

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • BlackBoxTV

    BlackBoxTV

    7 Mayıs 2007
  • gsipek

    gsipek

    20 Temmuz 2007
  • Tome Rodrigo

    Tome Rodrigo

    9 Temmuz 2006