Python
ターミナルでコマンドを実行しても文字が正しく出力されなくて、しばし困ってしまった。 しかし、ターミナルの環境設定→設定→詳細→言語環境→文字エンコーディング、でUnicode(UTF-8)にしたらなおった。 なんともつまらないことで時間を無駄にしてしまった…
#!/usr/bin/env python # -*- coding: utf-8 -*- import re import urllib2 fp = urllib2.urlopen('http://uni.2ch.net/wikileaks/subback.html') html = fp.read() match = re.findall('[0-9]{10}[//]', html) ita= "http://uni.2ch.net/test/read.cgi/wiki…
import re # encoding: shift_jis p=re.match(u"[あ-ん]+", u"おはよう御座います") print p.group() #「おはよう」と返る
import re p=re.compile('[a-z]+') m=p.match("abc") print m
#!/usr/bin/env python# -*- coding: utf-8 -*-import reimport urllib2fp = urllib2.urlopen('http://www.yahoo.co.jp’)html = fp.read()fp.close()data = htmlp = re.compile(r'<.*?>')res= p.sub('', data)f = open('text.txt', 'w')f.write(res)f.close(…
#!/usr/bin/env python# -*- coding: utf-8 -*-print 'こんばんは'
import urllib2fp = urllib2.urlopen('http://www.yahoo.co.jp/')html = fp.read()fp.close()f = open('text.txt', 'w')f.write(html)f.close()
import urllib2fp = urllib2.urlopen('http://www.yahoo.co.jp/')html = fp.read()fp.close()print html
import refrom mechanize import Browserbr = Browser()br.open('http://www.google.com/')br.title()for i in br.links():print i
Pythonの学習をはじめました。参考にしている文献は「みんなのPython Webアプリ編」です。私はAmazonで中古を購入しましたが、現在は著者のご厚意で無料でのダウンロードが可能なようです。 こちら↓ http://coreblog.org/ats/minpy-web-is-now-free-to-read …