20171006 encountered uncommon characters in write txt, using GB18030 encoding instead of gb2312 20170528 in reading XML in Chinese, output Chinese file jpg and there is a coding errorInvalid mode (' WB ') or filename: ' file/img/51190230001_\xe5\x88\x98\xe4\xbb\xb2\xe8\xb4\xa4.jpg 'approach:Imgname_nocode= ' {}_{}.jpg '. Format (name, Key.encode ("GBK")) gets: Panoramic view of the 51190230001_ Dam (hub). jpg20170113 Read the Chinese folder name, output Chinese file PDF and there is a coding error' \xb4\xa8\xcb\xae\xbd\xa8\xb9\xdc\xa3\xa82002\xa3\xa9655\xba\xc5approach:Fname=dir_listi.decode ("GBK") obtained: Sichuan Water Construction Pipe (2002) No. 65th, Bazhou District, LongDong Ditchafter 20151228_ reads the utf-8 characters in MySQL, writes SQL to?????Python has a way to convert any value into a string: pass it to the REPR () or str () function. The Chinese coding problem of 20140101_pythonHttp://blog.163.com/[email protected]/blog/static/1920560620146143153318/EXP7: Output Chinese to XML fileISO: Resolve Python output Chinese to XML file ASCII garbled problem modify the default encoding in the. py file [python] import sys reload (SYS) sys.setdefaultencoding (' UTF8 ') exp3: writes UTF8 in the read HTML to NotepadEncoding problem Unicodeencodeerror: ' ASCII ' codec can ' t encode characters in position 0-2: Ordinal not in range (+) author:lisoaring program:html2txt.py problem: Writes UTF8 in the read HTML to notepad such as: [U ' 110101000000 ', U ' \u4e1c\u57ce\u533a '] encounters: unicodeencodeerror: ' ASCII ' codec can ' t encode characters in position 0-2: Ordinal not in range (128) Workaround: 1, before the program add #-*-Coding:utf-8-*-2, the time of the string F.write (J.encode ("gb2312") + "\ T") exp2:python Chinese Conversion URL encodinghttp://blog.csdn.net/wangqiaoshi/article/details/9730247 exp5:MapInfo is GB encoded ====================================================================================EXP1:Write the tab delimiter in Notepad
\ t
exp4: Formatting a string of 1Import sysreload (SYS) sys.setdefaultencoding (' UTF8 ') F=open (R ' F:/out.txt ', ' W ') print >>f, ' <item id= '%s ' name = "%s" >\n <numxiang>%s</numxiang>\n </item>\n '% (one, "China", 3) F.close ()exp4-0: Formatting a string of 2file = open (' file/img/{}_{}.jpg '. Format (name, key), ' WB ') EXP6: Connection stringdelimiter = ', ' mylist = [' Brazil ', ' Russia ', ' India ', ' China ']print delimiter.join (mylist)EXP6: String to numeric to stringInt ()str () exp4-1: extracting numbers from a stringmethod: Regularkey= "tb189"I=re.findall (R "\d*", key) # # Print I j=int (i[2])%22 exp4-2: return Variable typemethod: Typy (a) exp4-2:python, add an XLS file that writes data to an already existing Excel file, that is, open the Excel files, write the new data
Lisoaring python string encoding