汉子转url编码 python3版

直接上代码 如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# date: 2015-08-31
# filename: zhtourl.py
#
# 中文转url编码
#
# The MIT License
#
# 使用说明,把需要转换的中文字符写入abc.txt,格式请参考abc.txt,result.txt为转换后的文件
#
# Copyright (c) 2015
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
from urllib.parse import quote
f = open("abc.txt", 'r', encoding='utf-8')
d = open("result.txt", "w", encoding="utf-8")
for x in f.readlines():
data1 = quote(str(x.strip('\n')))
d.write(data1+"\n")
d.close()
f.close()
if __name__ == "__main__":
input("输入任意键,退出:")

abc.txt 内容如下:

张伟
王伟
王芳
李伟
李娜
张敏
李静
王静
刘伟
王秀英
张丽
李秀英
王丽
张静
张秀英
李强
王敏
李敏
王磊
刘洋
王艳
王勇
李军
张勇
李杰
张杰
张磊
王强
李娟
王军
张艳
张涛
王涛
李艳
王超
李明
李勇
王娟
刘杰
刘敏
李霞
李丽
张军
王杰
张强
王秀兰
王刚
王平
刘芳
张燕
刘艳
刘军
李平
王辉

×

打赏一下

扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

文章目录
,