不多BB直接上代碼
import time
print("begin")
#讀取的txt文件
infile = open("god.txt","r");
#輸出的cer文件,當然你想輸出什麼格式都可以
outfile = open("god.cer","wb");
#開始讀文件
a = infile.read(1);
_combine = "";
i=0;
while a != '\n':
if ' ' == a:
a = infile.read(1);
continue;
else:
_combine = _combine + a;
i = i+1;
if 2 == i :
i = 0;
#此處轉化爲16進制
outfile.write(bytes.fromhex(_combine));
_combine = "";
a = infile.read(1);
infile.close();
outfile.close();
print("end")
python將txt轉16進制,內附有將16進制文本以ASCII碼格式存儲的txt文件,如果你已經安裝了python,可以直接在cmd中運行程序。
這個是py文件和txt文件的壓縮包,需要可以下載
python 163.py
這樣就成功了
到此,問題結束
如果沒有安裝python,點這裏去python官網下載
這裏我只說一下Windows安裝
1.建議選擇穩定版下載
2.下載完後安裝
2.1最好勾選 add python 3.x to path
2.2自己選擇安裝位置
3.打開cmd ,輸入python