2011年3月17日 星期四

[python] ttributeError: 'str' object has no attribute 'format'


下載了一個自動產生 pycon影音連結的python script

wget http://www.cngump.com/wp-content/uploads/2011/03/url_blip_tv.py_.zip

用的自己編的python
pcl99@gais4.cs.ccu.edu.tw[~/project/python/test][13:31](SCREEN 1)$ ~/bin/Python url_blip_tv.py
http://blip.tv/file/get/Pycon-PyCon2011DeployingWebApplicationsToTheCloud1of2113.mp4
Traceback (most recent call last):
File "url_blip_tv.py", line 26, in
html=html+"{0}
\n".format(url)
AttributeError: 'str' object has no attribute 'format'

出現了這個錯誤,
在用系統自帶的卻沒有錯誤,
原來自己的python是2.5的版本,
format是2.6之後才加入的python 3.0語法。
5. Built-in Types — Python v2.7.1 documentation
http://docs.python.org/library/stdtypes.html#string-formatting-operations

What’s New in Python 2.6 — Python v3.0.1 documentation
http://docs.python.org/release/3.0.1/whatsnew/2.6.html#pep-3101-advanced-string-formatting



沒有留言:

張貼留言