鍏充簬python缂栫爜

缂栫爜杞崲

骞冲父鍦ㄥ啓python浠g爜鏃剁粡甯搁亣鍒拌緭鍑轰贡鐮侊紝unicode銆乬bk銆乽tf-8绛夌瓑浠�涔堟椂鍊欒鐢ㄥ摢涓‘瀹炲緢鐑︺�傚鏁版儏鍐靛湪澶撮儴澹版槑浜哻oding:utf-8浼间箮骞舵病璧蜂綔鐢紵
鍏跺疄涓嶆槸杩欐牱鐨勩�傝璁叉垜鑷繁瀵逛簬 decode 鍜� encode 鐨勭悊瑙e惂

decode 涓� encode

decode 灏嗘煇绉嶇紪鐮佽В鐮佹垚 unicode
encode 灏� unicode 缂栫爜鎴愭煇绉嶇紪鐮�


鍦ㄦ垜鐨勭悊瑙d腑 unicode 鐩稿綋浜庝腑闂寸爜銆傚綋闇�瑕佹妸浣跨敤 gbk 缂栫爜鐨勭綉椤垫簮鐮佺敤python绋嬪簭杈撳嚭鏃跺叾鏂囨湰寰�寰�鏄贡鐮侊紝杩欐椂鍊欏彲浠ュ厛鎶� gbk decode鎴恥nicode锛屽啀鎶� unicode encode鎴� utf-8

html.decode('gbk').encode('utf-8')

你可能感兴趣的:(鍏充簬python缂栫爜)