Operating environment
Xeon E5-2620 v4 (8 cores) x 2
32GB RAM
CentOS 6.8 (64bit)
openmpi-1.8.x86_64 and its-devel
mpich.x86_64 3.1-5.el6 and its-devel
gcc version 4.4.7 (And gfortran)
NCAR Command Language Version 6.3.0
WRF v3.7.Use 1.
@ Introducing Python: Modern Computing in Simple Packages by Bill Lubanovic
int to string
It was written in the above book that when using int (), an error occurs in the description of the exponential format such as ʻint ('1e3') `(@ No.733 / 12833).
I've tried.
int_func_170120.py
ival1=int('1000')
print(ival1)
ival2=int('1e3')
print(ival2)
result
$ python int_func_170120.py
1000
Traceback (most recent call last):
File "int_func_170120.py", line 3, in <module>
ival2=int('1e3')
ValueError: invalid literal for int() with base 10: '1e3'
string to int
What I was curious about when doing the above was what if the 1e3
was converted to str.
I've tried.
str_func_170120.py
str1=str(1000)
print(str1)
str2=str(1e3)
print(str2)
result
1000
1000.0
The number 1e3 seems to be a string type after being converted to 1000.0.
It was also mentioned in the above book (@ No. 831/12833).
Recommended Posts