Position: Home page » Currency » Python conversion currency type number

Python conversion currency type number

Publish: 2021-04-18 14:13:05
1. def func(money):
return f' RMB: 20 US dollars: {money * 20} & # 39

I don't know what you mean, but it's very simple. I don't know what effect you want. You'd better give an example, such as what to input and what to output
2.
#coding:utf-8
deftranslate(st="你要转换的字符串"):
try:
num=int(st)
returnnum
except:
#print""%s"isnotaninteger."%st
pass
try:
num=float(st)
returnnum
except:
#print""%s"isnotafloat."%st
pass
try:
num=complex(st)
returnnum
except:
#print""%s"isnotafloat."%st
pass
returnst#返回原串表示转换失败
3.
#!/ usr/bin/envpython
# coding:utf-8
dict={u' Zero & 39;: 0,u' 1.39;: 1,u' (2) the following is true: 2,u' 3.39;: 3,u' 4.39;: 4,u' V. & 39;: 5,u' (6) the following is true: 6,u' 7.39;: 7,u' 8.39;: 8,u' 9.39;: 9,u' X-39;: 10,u' In this paper, we present a new method to solve this problem 100,u' Thousand and thirty nine;: 1000,u' Million and 39;: 10000,
u' 0': 0,u' 1': 1,u' 2': 2,u' 3': 3,u' 4': 4,u' 5': 5,u' 6': 6,u' 7': 7,u' 8': 8,u' 9': 9,
u' First, the following is true: 1,u' (2) the following is true: 2,u' 3.39;: 3,u' 4.39;: 4,u' Wu & Chen 39;: 5,u' Lu and Chen 39;: 6,u' Chapter 7: 7,u' 8.39;: 8,u' Chapter 9: 9,u' Pick up 39;: 10,u' 39;: 100,u' The following is true: 1000,u' Million and 39;: 10000,
u' Billion and 39;: 100000000}
defgetResultForDigit(a,encoding=" utf-8"):< br />ifisinstance(a,str):
a=a.decode(encoding)
count=0
result=0
tmp=0
Billion=0
whilecount< Len (a):
tmpcr = a [count]
#printtmpcr
tmpnum = dict.get (tmpcr, none)
#if it is equal to 100 million
iftmpnum = = 100000000:
result = result + TMP
result = result * tmpnum
#, Save it in the middle variable bill and clear result
bill = bill * 100000000 + result
result = 0
TMP = 0
# if it is equal to 10000
eliftmpnum = = 10000:
result = result + TMP
result = result * tmpnum
TMP = 0
# if it is equal to ten thousand or hundred, thousand
eliftmpnum & gt= 10:
iftmp = = 0:
TMP = 1
result = result + tmpnum * TMP
TMP = 0
if it is a single digit
eliftmpnumisnotnone:
TMP = TMP * 10 + tmpnum
count + = 1
result = result + TMP
result = result + bill
return result
if__ name__==& quot;__ main__& quot;:< br />test_ map={
' 3523-39;: 3523,
' Seven hundred and fifty eight million seventy nine thousand two hundred and eight 7508079208,
' 43521 43521,
' 3521-39;: 3521,
' Three thousand five hundred and eight 3508,
' 3560 and 39;: 3560,
' Ten thousand thirty-nine: 10030,
'&# 39;: 0,
, 1 digit
& 39; Zero & 39;: 0,
' 1.39;: 1,
' (2) the following is true: 2,
' 3.39;: 3,
' 4.39;: 4,
' V. & 39;: 5,
' (6) the following is true: 6,
' 7.39;: 7,
' 8.39;: 8,
' 9.39;: 9,
? 2digits x
? 39; X-39;: 10,
' Chapter 11 11,
' Twenty thirty nine;: 20,
' 21-39;: 21,
, 39; One hundred and thirty-nine;: 100,
' 101-39;: 101,
' 110 and 39;: 110,
' 123-39;: 123,
, 4digits thousand
& 39; One thousand and thirty-nine;: 1000,
' One thousand and one 1001,
' 11039;: 1010,
' One thousand one hundred 1100,
' 1023 & 39;: 1023,
' One thousand two hundred and three 1203,
' One thousand two hundred thirty 1230,
# 5digits million
& # 39; Ten thousand 10000,
' Ten thousand and one 10001,
' Ten thousand and ten thousand and thirty-nine 10010,
' Ten thousand and one hundred 10100,
' Eleven thousand 11000,
' Ten thousand and eleven 10011,
' Ten thousand and one hundred and thirty-nine 10101,
' Eleven thousand and one 11001,
' Ten thousand one hundred and ten 10110,
' Eleven thousand ten 11010,
' Eleven hundred and thirty nine: 11100,
' Ten thousand one hundred and ten 11110,
' Eleven thousand one 11101,
' Eleven thousand eleven 11011,
' Ten thousand one hundred and eleven 10111,
' Eleven and eleven 11111,
, hundreds of thousands of digits
& 39; 100000 02345 102345,
' 123456 123456,
' One hundred thousand three hundred fifty-six 100356,
' One hundred thousand three thousand six hundred nine 103609,
, 7digits million
& 39; One million two hundred and thirty-four thousand five hundred and sixty-seven 1234567,
' One million one hundred and one 1010101,
' One million and one million 1000001,
? 8digits million
? 39; Eleven million two hundred thirty-four thousand five hundred sixty-seven 11234567,
' 10.1110101 10110101,
' $10.01 million 10000001,
, 9digits billion
& 39; 111.234.567 111234567,
' 101 million and 101 million 101010101,
' 101 million 10000001,
, 10 billion digits
& 39; 1111.234.567 1111234567,
ාාාා11 billion
& ාා39; 11.111.234567 11111234567,
, 12digits 100 billion
& 39; 111.11 billion, 111.23 million, 5567 111111234567,
, 13 digits trillion
& 39; 111.11 billion 111.23 million 5567 1111111234567,
, 14digitas billion
& 39; 111.11 billion 111.234 million 567 11111111234567,
, 17 digits billion
& 39; 111.111.111.111.111.111.212.34567 11111111111234567,
}
foreachintest_ map:
assert(test_ Map [Each] = = getresultfordigit (each)) < / pre >

the function of assert is to judge getresultfordigit and test_ Are the corresponding key values in the map consistent

4. The integer string is converted to the corresponding integer
int (&? 39; 12')
convert decimal string to corresponding decimal; 12.34')
conversion of number to string
str (123.45)
conversion of ASCII code to corresponding character
Chr (97)
conversion of character to response ASCII code
ord (&# 39; a')
5.

(1) import string

t = & 39; 555'

TS = string. ATOI (TT)

TS is the number converted from TT

to floating point string. Atof (TT)

(2) direct int

int (TT)< Second, the number is converted to a string

TT = 322

TEM = & 39;% d' % TT

tem is the string converted from TT

extended materials:

Python is an organized and powerful object-oriented programming language, similar to Perl, ruby, scheme, Java. One of the design goals of Python is to make the code highly readable. It is designed to use punctuation marks and English words often used in other languages to make the code look neat and beautiful. Unlike other static languages such as C and Pascal, it does not need to write declaration statements repeatedly, nor does it often have special situations and accidents like their syntax

6. Here's an idea for you:
1. Use regular expressions to extract the data you require, the first two letters and the last four digits
2. Separate the extracted data into two parts: letters and numbers
3. Convert the extracted number part
4. Then splice the letters with the converted numbers. This step is optional

of course, there is a simple method. The above idea is clear, but it is relatively cumbersome and low

I hope I can help you......
7.
Python3.5.2(v3.5.2:4def2a2901a5,Jun252016,22:01:18)[MSCv.190032bit(Intel)]onwin32
Type " Can not open message " ", " (Laughter) or license " Formoreinformation.
> & gt; & gt; s1=& #39; 123 ' < br/>> & gt; & gt; s1
& #39; 123 ' < br/>> & gt; & gt; i1=int(s1)
> gt; & gt;
123
> gt; & gt; Type(i1)
< Class & #39; int ' & < br/>> & gt; & gt; s2= & #39; 123.4 ' < br/>> & gt; & gt; f2=float(s2)
> gt; & gt; f2
123.4
> gt; & gt; Type(f2)
< Class & #39; Float ' &
8. Unknown_Error
9.

First of all, it should be noted that (1) is an integer, and (1,) is a tuple

conversion type

b = str (a) # to string

b = int (a) # to plastic

and then you can use type (b) to verify

10. With this program design, the conversion of these two currencies is very simple, because it is very simple to convert according to the conversion rate, and then multiply by its conversion rate.
Hot content
Inn digger Publish: 2021-05-29 20:04:36 Views: 341
Purchase of virtual currency in trust contract dispute Publish: 2021-05-29 20:04:33 Views: 942
Blockchain trust machine Publish: 2021-05-29 20:04:26 Views: 720
Brief introduction of ant mine Publish: 2021-05-29 20:04:25 Views: 848
Will digital currency open in November Publish: 2021-05-29 19:56:16 Views: 861
Global digital currency asset exchange Publish: 2021-05-29 19:54:29 Views: 603
Mining chip machine S11 Publish: 2021-05-29 19:54:26 Views: 945
Ethereum algorithm Sha3 Publish: 2021-05-29 19:52:40 Views: 643
Talking about blockchain is not reliable Publish: 2021-05-29 19:52:26 Views: 754
Mining machine node query Publish: 2021-05-29 19:36:37 Views: 750