background preloader

Api

Facebook Twitter

Python Imaging Library PIL. Mise à jour: 25 juin 2009Version: 1.0Author: Jean-Louis Bicquelet-Salaün Location: (c) 2009 Jean-Louis BICQUELET-SALAÜN FAQ Revised: Friday 26 June 2009 18:17:03 Table of Contents 1. generalité 1.1. Qu'est-ce que PIL ? 2. information 3. transformation 4. manipulation 1. generalité 1.1. La bibliothèque Python Imaging Library (PIL) ajoute des capacités de traitement d'image à votre interpréteur Python. 2. information 2.1. On remarquera, l'utilisation du try/except afin de gérer correctement les erreurs. From PIL import Image file='cours.png' try: im = Image.open(file) print file, im.format, "%dx%d" % im.size, im.mode except IOError: pass L'affichage donne ceci: cours.png PNG 230x150 RGB 2.2. From PIL import Image import ImageFilter im = Image.open('cours.png') im.show() 3. transformation 3.1. Exemple: 3.2. Les formats possibles sont: exemple: from PIL import Image im = Image.open('cours.png') im.save('cours.jpg', "JPEG") im.save('cours.bmp', "BMP") 3.3.

Ou 3.4. 3.5. 3.6. Python - How do I create a macro, using Bottle's SimpleTemplate engine, that will be available in several templates. [mac] Install Python MySQLdb to MAMP « resource log. Because I’m lazy to install Apache + MySQL + PHP separately, so in the first place, I use MAMP. But this becomes a problem when I’m going to install MySQLdb python library. Here is how to resolve it. After downloaded the file MySQL-python-1.2.3.tar.gz, extract to a folder and edit one of the file setup_posix.py Then add below line to ~/.bash_profile. This might be optional but for my case, I’ve added it and sourceit. This is because if not adding it, it will keep assume I’m using 64bit, but in fact, mine is 32bit only. After that, execute the below command At this point, you have your library installed. Library not loaded: libmysqlclient.18.dylibReferenced from: /Users/<user>/.python-eggs/MySQL_python-1.2.3-py2.6-macosx-10.6-universal.egg-tmp/_mysql.soReason: image not found Above case, might need to install additional MySQL, seem MAMP doesn’t have library requested.

Like this: Like Loading... Crée vos logiciels - Le blog: Logiciels, Web, Python, Javascript ... Il existe de nombreux frameworks de développement web en Python. Le plus connu, et à mon avis le plus efficace, reste Django mais je voudrais vous présenter Bottle, une solution très légère dont la philosophie est complètement différente de celle de Django. Idéal pour développer très rapidement par exemple une IHM web. La légèreté comme philosophie Django se veut le framework des perfectionnistes sous pression. Il est pensé comme une solution complète apportant l'ensemble des outils nécessaires pour développer rapidement un site internet. Il gère en particulier la base de données, les utilisateurs, le site d'administration et bien plus encore. Bottle a une approche beaucoup plus minimaliste d'un framework web. Une page web = Une fonction Python Du point de vue du code, là aussi Bottle recherche la légèreté.

Import bottle@bottle.route("/")def index(): return "Hello world! " bottle.run() #lance le serveur web en localhost sur le port 8080 Les décorateurs pour simplifier le développement. Docs/dev/bottle-docs.pdf. FrontPage - The PEAK Developers' Center. NOTE: Due to rampant spammer edits, this wiki is no longer open to public editing. Email me your user name and login ID if you want to get access.

(If your name isn't shown in the upper right corner of this page, you can click on "UserPreferences" to sign up (with a valid e-mail address) and log in. However, to actually edit anything, I'll need to grant permission to your login first.) Getting Started When beginning to learn PEAK, the best order in which to explore the modules is: binding, config, and naming. The next layer to explore should probably be the runtime modules: ? The storage module provides numerous storage management features, including high level relational database connectivity, a general transaction framework with ACID assurance and two-phase commit, and a ?

The model module provides a framework for implementing the ? The events module provides an "event-driven" programming framework that supports ultralight "microthreads" implemented via generators. Tutorials Concepts. Python expression régulière pour HTML Parsing (beautifulsoup) Pyparsing est une bonne étape intermédiaire entre BeautifulSoup et regex.

Il est plus robuste que regexes juste, depuis son analyse balise HTML comprend les variations de cas, les espaces, attribuent la présence / absence / commande, mais c'est plus simple de faire ce genre d'extraction tag de base que l'utilisation de BS. Votre exemple est particulièrement simple, puisque tout ce que vous cherchez se trouve dans les attributs de l'ouverture "d'entrée" tag. Voici un exemple montrant pyparsing plusieurs variantes sur votre balise d'entrée qui donnerait regex correspond, et montre aussi comment ne pas compenser une étiquette si elle est dans un commentaire: html = """ from pyparsing import makeHTMLTags, withAttribute, htmlComment # use makeHTMLTags to create tag expression - makeHTMLTags returns expressions for # opening and closing tags, we're only interested in the opening tag inputTag = makeHTMLTags("input")[0] # only want input tags with special attributes inputTag.ignore(htmlComment) print.

BeautifulSoup - comment extraire ou manipuler une page html en Python. Introduction Dans la vie d'un programmeur, il peut être un jour nécessaire d'extraire des informations depuis une page web. Mais tout le monde n'a pas envie de se prendre la tête avec le format HTML ni envie de savoir exactement comment cela fonctionne. Si vous avez seulement besoin d'extraire des informations depuis le Web, Beautiful Soup est le module qu'il vous faut. Beautiful Soup est un parser HTML/XML pour Python qui permet de créer un arbre à partir d'un document HTML même si ce dernier contient des incohérences dans les balises. Beautiful Soup offre des possibilités de navigation idéomatique simple, il est également possible de faire des recherches et des modifications de document HTML. Beautiful Soup fait partie de cette catégorie d'outil qui permet de d'épargner de nombreuses et laborieuses heures/journées de travail. Beautiful Soap stocke uniquement des chaines de caractère Unicode.

Beautiful Soup et XML Installation. Beautiful Soup: We called him Tortoise because he taught us. [ Download | Documentation | Hall of Fame | For enterprise | Source | Changelog | Discussion group | Zine ] You didn't write that awful page. You're just trying to get some data out of it. Beautiful Soup is here to help. Since 2004, it's been saving programmers hours or days of work on quick-turnaround screen scraping projects.

Beautiful Soup is a Python library designed for quick turnaround projects like screen-scraping. Three features make it powerful: Beautiful Soup provides a few simple methods and Pythonic idioms for navigating, searching, and modifying a parse tree: a toolkit for dissecting a document and extracting what you need. Beautiful Soup parses anything you give it, and does the tree traversal stuff for you. Valuable data that was once locked up in poorly-designed websites is now within your reach.

Interested? Getting and giving support If you have questions, send them to the discussion group. Download Beautiful Soup The current release is Beautiful Soup 4.9.1 (May 17, 2020). Le NoSQL dans le domaine géospatial, approche préliminaire en Python avec SimpleGeo. Que signifie NoSQL ? Ce terme désigne une nouvelle catégorie de bases de données qui n'utilisent ni la notion relationnelle des SGBDR classiques, ni le langage SQL. NoSQL signifie en fait « Not Only SQL ».

Ces bases de données sont vraiment nées en 2009 (certaines existent depuis la fin des années 80) en réaction à la complexité des bases de données classiques et pour une utilisation dans l’« informatique dans les nuages » (cloud computing) du fait des nécessités de rapidité, de performance et des besoins en termes de charge et de volume de données (à titre d'exemple, toute la gestion du magasin en ligne Amazon est effectuée avec une base NoSQL).

Elles ont été créées et/ou sont actuellement utilisées par Google, Facebook, Ebay, Amazon, Twitter et autres pour leurs besoins propres. Principes Ces bases peuvent être classées en quatre grandes familles: Clé-valeur (Key-value Stores): les données sont représentées par un couple clé/valeur. Leur utilisation dans le domaine géospatial SimpleGeo. Ping et Python. Building python 2.6.4 RPM for CentOS 5.4 | GrenadePod. Twisted. Twisted is an event-driven networking engine written in Python and licensed under the open source ​MIT license. Twisted runs on Python 2 and an ever growing subset also works with Python 3. Twisted makes it easy to implement custom network applications. Here's a TCP server that echoes back everything that's written to it: from twisted.internet import protocol, reactor, endpoints class Echo(protocol.Protocol): def dataReceived(self, data): self.transport.write(data) class EchoFactory(protocol.Factory): def buildProtocol(self, addr): return Echo() endpoints.serverFromString(reactor, "tcp:1234").listen(EchoFactory()) reactor.run() Learn more about ​writing servers, ​writing clients and the ​core networking libraries , including support for SSL, UDP, scheduled events, unit testing infrastructure, and much more.

Twisted includes an event-driven web server. Learn more about ​web application development, ​templates and Twisted's ​HTTP client. Twisted includes a sophisticated IMAP4 client library. Pyfilesystem - Project Hosting on Google Code. Pyfilesystem is a Python module that provides a simplified common interface to many types of filesystem. Filesystems exposed via Pyfilesystem can also be served over the network, or 'mounted' on the native filesystem. Pyfilesystem simplifies working directories and paths, even if you only intend to work with local files. Differences in path formats between platforms are abstracted away, and you can write code that sand-boxes any changes to a given directory. Pyfilesystem works with Linux, Windows and Mac. Suported Filesystems Here are a few of the filesystems that can be accessed with Pyfilesystem: Example The following snippet prints the total number of bytes contained in all your Python files in C:/projects (including sub-directories). from fs.osfs import OSFS projects_fs = OSFS('C:/projects') print sum(projects_fs.getsize(path) for path in projects_fs.walkfiles(wildcard="*.py")) That is, assuming you are on Windows and have a directory called 'projects' in your C drive.

Screencast. Simplegeo/python-oauth2 - GitHub.