十一月 | ||||||
---|---|---|---|---|---|---|
日 | 一 | 二 | 三 | 四 | 五 | 六 |
27 | 28 | 29 | 30 | 31 | 1 | 2 |
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
python笔记
BeautifulSoup
how to get the address(href=) <a></a> tag refer to.
from BeautifulSoup import BeautifulSoup print soup('a')[0]['href'] # equivalent to soup.findAll('a')
如果用find或者findNext,返回的不是列表,则不需要[0]。
Python Issue 1521491
遇到一个win xp+python2.5.1/python2.6.4上'a+'模式读写文件的bug,写文件时报错:IOError: [Errno 0] Error。stackoverflow上搜到讨论,该bug(Python Issue Tracker上的页面)似乎在win xp + python 2.5/python2.6上都会出现,这里有讨论如何避开该bug:
this is pilot error, inherited from the limitations of C I/O: the effect of mixing reads with writes on a file open for update is entirely undefined unless a file-positioning operation occurs between them (for example, a seek()).
在f.read()和f.write()间插入f.seek(f.tell())。
acc_file = open('bla_path', 'at+') acc_str = acc_file.read() acc_file.seek(acc_file.tell()) acc_file.write('bla')
PyInstaller
.py文件复制到python目录下(譬如Python2.5.1),在这个目录下运行:
> python <PyInstaller Dir>/Makespec.py --onefile your_prog.py > python <PyInstaller Dir>/Build.py your_prog.spec
该目录dist下会生成名为your_prog的目录。创建.spec文件时的参数可查询pyinstaller-1.5\doc\Manual.html。
参考介绍:PyInstaller使用简介。
Unicode
很好的presentation:Unicode in Python。
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe4 in position 0: ordinal not in range(128)的解决方法。
pyExcelerator
2022年9月25日 12:27
Every year the BSEB is provided the latest updated model question paper for intermediate Hindi Medium and English Medium students from past years old examination set wise question paper with expert answers to theory and objective type questions for all subjects of Hindi, English, Mathematics, Physics, Chemistry, Biology, Computer Science, Bihar Board 12th Science Model Paper Multimedia & Web Technology for BSEB Inter science stream students.Every year the BSEB is provided the latest updated model question paper for intermediate Hindi Medium and English Medium students from past years old examination set wise question paper with expert answers to theory and objective type questions for all subjects .