FarewellRain
V2EX  ›  问与答

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

  •  
  •   FarewellRain · Aug 28, 2019 · 1580 views
    This topic created in 2477 days ago, the information mentioned may be changed or developed.

    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 时显示不正常,不能得到正确的结果
    麻烦懂的朋友指导一下
    谢谢!
    
    1 replies    2019-08-28 17:12:59 +08:00
    FarewellRain
        1
    FarewellRain  
    OP
       Aug 28, 2019
    代码用了 markdown 还是不太友好
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5649 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 03:37 · PVG 11:37 · LAX 20:37 · JFK 23:37
    ♥ Do have faith in what you're doing.