相关疑难解决方法(0)

使用D代替E的Python科学记数法

Fortran程序生成的一些结果文件使用字母D而不是E例如报告双精度数字(科学记数法):

1.2345D+02
# instead of
1.2345E+02
Run Code Online (Sandbox Code Playgroud)

我需要使用Python处理大量的这些数据,我只是意识到它无法读取D符号中的数字,例如:

>>> A = 1.0D+01
  File "<stdin>", line 1
    A = 1.0D+01
           ^
SyntaxError: invalid syntax
Run Code Online (Sandbox Code Playgroud)

我可以更改我的语言环境,让Python知道这D意味着E什么?我真的不想进行全球搜索和替换!

python locale scientific-notation

11
推荐指数
3
解决办法
7184
查看次数

标签 统计

locale ×1

python ×1

scientific-notation ×1