# -*- coding:utf-8 -*- import sys,os txta = open('a.txt','r') str = '' for line in txta: str += line.strip().decode('utf-8') txta.close() for word in str: print word.encode('utf-8') 直接输出,是会乱码的,得先解码,再编码. 参考网址:http://blog.csdn.net/devil_2009/article/de…
python中字符串可以(且仅可以)使用成对的单引号.双引号.三个双引号(文档字符串)包围: 'this is a book' "this is a book" """this is a book""" 可在单引号包围的字符串中包含双引号,三引号等,但不能包含单引号自身(需转义) 'this is a" book' 'this is a"" book' 'this is a""…