Giter Site home page Giter Site logo

alfred_numtocny's Introduction

GitHub Stats Top Languages

alfred_numtocny's People

Contributors

leoleozhu avatar yourtion avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

alfred_numtocny's Issues

发现了点问题,建议更新下

使用时发现有点问题,修正了下。
一是在万圆时没有圆字;
二是在万亿时有错误;

``` python````

-- coding: utf-8 --

import math
def numtoCny(num):
capUnit = ['万','亿','万','圆','']
capDigit = { 2:['角','分',''], 4:['仟','佰','拾','']}
capNum=['零','壹','贰','叁','肆','伍','陆','柒','捌','玖']
snum = str('%019.02f') % num
if snum.index('.')>16:
return '输入数据过长'
ret,nodeNum,subret,subChr='','','',''
CurChr=['','']
for i in range(5):
j=int(i*4+math.floor(i/4))
subret=''
nodeNum=snum[j:j+4]
lens=len(nodeNum)
for k in range(lens):
if int(nodeNum[k:])==0:
continue
CurChr[k%2] = capNum[int(nodeNum[k:k+1])]
if nodeNum[k:k+1] != '0':
CurChr[k%2] += capDigit[lens][k]
if not ((CurChr[0]==CurChr[1]) and (CurChr[0]==capNum[0])):
if not((CurChr[k%2] == capNum[0]) and (subret=='') and (ret=='')):
subret += CurChr[k%2]
subChr = [subret,subret+capUnit[i]][subret!='']
if not ((subChr == capNum[0]) and (ret=='')):
ret += subChr
####万亿时没有亿字
if len(str(int(num)))>12 and len(str(int(num)))-j<13 and (capUnit[1] not in ret):
ret += capUnit[1]
####万圆时没有圆字
if ret and (not ret.endswith(capUnit[3])):
ret+=capUnit[3]

return [ret,capNum[0]+capUnit[3]][ret=='']  

def callback(strs):
print('')
print('')
print(" <item uid="octal" valid="yes" arg=""+strs+"">")
print(" <title>"+strs+"</title>")
print(' Copy to clipboard')
print(' icon.png')
print(' ')
print('')

callback(numtoCny({query}))

arg of res in source.py

I think your code in source.py has a little problem. Maybe the "arg" of "res" should be ret

还是万亿的问题,需要添加限制

使用这个会有问题。
cny 10000,0000,1234
壹万亿壹仟贰佰叁拾肆圆整

    #处理万亿以上的部分
    if integer_part >= 1000000000000 and wanyi_part > 0:
        zero_count = _parse_integer(strio, wanyi_part, zero_count, True)
        if yi_part > 0:
            strio.write('万')
        else:
            strio.write('万亿')

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.