关于 code128c 中间有多个 0 出现的问题

2019-08-28 17:01:40 +08:00
 FarewellRain

def code128C(s): checksum = 105 j = 1 result = '' for i in range(0, len(s), 2): checksum += int(s[i:i + 2], base=10) * j print(s[i:i + 2], j, checksum) if int(s[i:i + 2]) < 95: result += chr(int(s[i:i+2]) + 32) j += 1 else: result += chr(int(s[i:i+2]) + 100) j += 1 checksum %= 103 checksum += 32 if checksum < 95 else 100 retval = chr(205) + result + chr(checksum) + chr(206) return retval.decode('iso8859_1').encode('utf-8')

当条码号中有一组 0 时,打印的字符串在 code128 字体下显示有问题,扫码后不能得到条码号。
例如:当条码号为 1999100212 能显示正常,当条码为 199910000212 时显示不正常,不能得到正确的结果
麻烦懂的朋友指导一下
谢谢!
856 次点击
所在节点    问与答
1 条回复
FarewellRain
2019-08-28 17:12:59 +08:00
代码用了 markdown 还是不太友好

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/595954

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX