gpt4 book ai didi

python - 我需要将邮政编码更改为一系列点和破折号(条形码),但我不知道如何

转载 作者:行者123 更新时间:2023-11-28 20:29:13 30 4
gpt4 key购买 nike

这是我到目前为止所得到的:

def encodeFive(zip):

zero = "||:::"

one = ":::||"

two = "::|:|"

three = "::||:"

four = ":|::|"

five = ":|:|:"

six = ":||::"

seven = "|:::|"

eight = "|::|:"

nine = "|:|::"

codeList = [zero,one,two,three,four,five,six,seven,eight,nine]

allCodes = zero+one+two+three+four+five+six+seven+eight+nine

code = ""
digits = str(zip)
for i in digits:

code = code + i

return code

有了这个,我将获得字符串中的原始邮政编码,但没有任何数字被编码到条形码中。我已经想出如何对一个数字进行编码,但它不会以同样的方式处理五个数字。

最佳答案

codeList = ["||:::", ":::||", "::|:|", "::||:", ":|::|",
":|:|:", ":||::", "|:::|", "|::|:", "|:|::" ]
barcode = "".join(codeList[int(digit)] for digit in str(zipcode))

关于python - 我需要将邮政编码更改为一系列点和破折号(条形码),但我不知道如何,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2798766/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com