我在尝试格式化字段时遇到问题。
(我的例子中的imshow
代表空格)
我需要这样做:#!/usr/bin/env python
import numpy as np
from pylab import *
nn = 1000
nx = nn
ny = nn
xs = np.linspace(0.0, 10.0, nx)
ys = np.linspace(0.0, 10.0, ny)
fs = np.zeros([nx,ny])
fmax = 4000.0
natoms = 4
Xs = 10.0*random(natoms)
Ys = 10.0*random(natoms)
als = 10.0*random(natoms)
for ix in range(nx):
x = xs[ix]
for iy in range(ny):
y = ys[iy]
fv = 0.0
for iat in range(natoms):
X = Xs[iat]
Y = Ys[iat]
r = sqrt( (X-x)*(X-x) + (Y-y)*(Y-y) )
al = als[iat]
fv += fmax*exp( -al*r )
fs[ix,iy] = fv
figure(1)
imshow(fs)
figure(2)
A = np.zeros([nx, ny, 3])
A[:,:,0] = np.copy(fs)
imshow(A)
show()
我尝试使用这样的s
,但我得到了这个:sssssssss$37,189.50
我也试过这样做$%1$,.f
,但我明白了:$37,189.50sssssssss