Erinevus lehekülje "Python" redaktsioonide vahel
Allikas: Kuutõrvaja
(→Unicode) |
|||
11. rida: | 11. rida: | ||
* http://docs.python.org/3.1/library/http.client.html | * http://docs.python.org/3.1/library/http.client.html | ||
+ | |||
+ | Skript http päringu vastuse päise elemendi esitamiseks | ||
+ | |||
+ | import httplib | ||
+ | conn = httplib.HTTPConnection("www.python.org") | ||
+ | conn.request("GET", "/index.html") | ||
+ | r1 = conn.getresponse() | ||
+ | print r1.getheader('last-modified') | ||
===Unicode=== | ===Unicode=== | ||
16. rida: | 24. rida: | ||
* http://docs.python.org/3.1/howto/unicode.html | * http://docs.python.org/3.1/howto/unicode.html | ||
− | + | Skript UTF-8 formaadis faili kirjutamiseks (sisuks on Ä ja à tähed) | |
− | + | file = open('utf8data.txt', 'w', encoding='utf-8') | |
− | + | size = file.write('\xc4\xc3\n') | |
− | + | file.close () | |
===Kasulikud lisamaterjalid=== | ===Kasulikud lisamaterjalid=== |
Redaktsioon: 24. veebruar 2010, kell 00:21
Sissejuhatus
Python http://www.python.org/ ...
2010 aastal on levinud kasutada kahte erinevat Pyhton keele põlvkonda, sõltuvalt kasutusalast võib see olla oluline, kumba konkreetsel juhul eelistada
- 2.x - ...
- 3.x - ...
Võrk
Skript http päringu vastuse päise elemendi esitamiseks
import httplib conn = httplib.HTTPConnection("www.python.org") conn.request("GET", "/index.html") r1 = conn.getresponse() print r1.getheader('last-modified')
Unicode
Skript UTF-8 formaadis faili kirjutamiseks (sisuks on Ä ja à tähed)
file = open('utf8data.txt', 'w', encoding='utf-8') size = file.write('\xc4\xc3\n') file.close ()
Kasulikud lisamaterjalid
- http://www.python.org/
- Learning Python, 4rd editon (v. 2.6 ja 3.0), Mark Lutz