將字符串每2個字符分為一組,間隔的插入空格
import re
string = "aaaaaa270020110020ed810008f581000"
# 寫出正則表達式 任意2個字符
pattern = re.compile('.{2}')
# findall是找到所有的字符,再在字符中添加空格,當然你想添加其他東西當然也可以
print(' '.join(pattern.findall(string)))
import re
string = "aaaaaa270020110020ed810008f581000"
# 寫出正則表達式 任意2個字符
pattern = re.compile('.{2}')
# findall是找到所有的字符,再在字符中添加空格,當然你想添加其他東西當然也可以
print(' '.join(pattern.findall(string)))
aa aa aa 27 00 20 11 00 20 ed 81 00 08 f5 81 00
本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。