#author("2017-04-05T13:45:38+09:00","","") #author("2017-04-09T21:57:17+09:00","","") ZZZZZZZZ -Python?≫???iki --[[Python]] --[[Python/MySQL]] --[[Python/urllib]] --[[Python/?????吾?с????????]] --[[Python/紊????????違????絎?茵?]] --[[Python/?潟???潟?????ゃ??] --[[Python/?潟?潟????]] --[[Python/?????????若??] --[[Python/?ヤ??紙????]] --[[Python/???<?ゃ??] --[[Python/?<?≪??] --[[Python/??絖???]] ---- -[[??絖????<?純????:http://www.python.jp/doc/2.5/lib/string-methods.html]] -[[??絖?????篏????莠?茵? Ruby, Python, JavaScript, Perl, C++:http://0xcc.net/blog/archives/000137.html]] * Unicode [#cd742a3b] -[[Python??nicodeEncodeError???ャ??:http://lab.hde.co.jp/2008/08/pythonunicodeencodeerror.html]] ... Python?ф?ユ???????????????茯????鴻?? ** ?堺? [#hfde4136] -??unicode???????????????違??UTF-8??絖??潟?若??????膈?????Unicode????絖??????????ョ?????с???? -python?у?初?????????????????ゃ?????????≪?????宴?若?激?с?括??с????unicode???с???ュ?阪?????????????????????????祉????? -python?ф?ユ??????宴???翫????????????nicode?????????????????♂? -unicode?????<?純???? --encode( [??絖??潟?若??] ) ... unicode?????劫?????絖??潟?若???????ゃ????鐚???tr??鐚??????潟?潟?若?? --decode() ... ?劫?????絖??潟?若???????ゃ????鐚???tr??鐚??????潟?若??????nicode??????? --??絖??潟?若???????ャ???????????翫????????????絖??潟?若??????絎??????????????宴?若?鴻?с???潟?潟?若?????????????違????????絮??≪?с????encode??str??ys.getdefaultencoding()?у???с?????????????????????潟?潟?若???c?潟?違?????ゃ??篏睡? ** UnicodeEncodeError ???冴???????????? [#h94bc206] Python?ф?ユ??????????????????????????????若??????冴???? UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-12: ordinal not in range(128) ???????????若???冴????????????札筝???茵??? -?障????????∈茯? type(ustr) <type 'unicode'> -unicode?? -> str?? ustr.encode('utf_8') - 罔?羣?????絖??潟?若????∈茯? >>> import sys >>> print sys.stdout.encoding UTF-8 * ??絖??潟?若???ゅ? [#k258b40b] -[[Python ?с???ユ?????絖??潟?若???ゅ?:http://junaraki.net/blog/2009/04/09/177.html]] * ??絖??????? ?∽?遺?荀 [#h916e1ba] -??絖??? ?? ?医? --int(str) --float(str) --long(str) --complex(str) -?医? ?? ??絖??? --str(f) -?劫???絖??ゅサ --rstrip() ... 茵???????醇??絖????????ゃ?????絖?????絎????????翫??? '\t', '\n', '\r', '\v', '\f' ???ゅサ???????? -??絖????????鴻??????? --split(ch) ... ??絎???絖??у?阪???c??腟????????鴻?????????? -??絖?????窪絲??????喝??? --ljust(width[, fillchar]) ... width ???激???????ゅ窪絲?????????絖?????菴??????????c?潟?違??? fillchar ?ф??絎?????????絖?(???????????с???鴻???若?刻???篏帥???????width ?? len(s) ??????絨?????翫??????????絖?????菴????????? --rjust(width[, fillchar]) ... width ???激???????ゅ勀?????????絖?????菴??????????c?潟?違??? fillchar ?ф??絎?????????絖?(???????????с???鴻???若?刻???篏帥???????width ?? len(s) ??????絨?????翫??????????絖?????菴????????? * Tips [#k4113133] -[[???潟????????絖???????:http://d.hatena.ne.jp/odz/20070821/1187682903]]