我正在尝试运行此代码,对我拥有的每一帧运行相同的命令(几乎没有变化):
traj.reset()
import os
#os.chdir(outname)
for i, frame in enumerate(traj):
frame.superpose()
comando = "python hollow.py -c constraint -o hollow_%s.pdb urei%s.pdb" % (i, i)
os.system(comando)
pml_cmd = "pymol urei%s.pdb hollow_%s.pdb -c -d 'as cartoon, urei%s;color gray90, urei%s;center chain A;set_view (\-0.605158150,0.089404292,0.791067421,\0.795849979,0.093013920,0.598304033,\-0.020089993,0.991641700,-0.127439827,\0.000000000,0.000000000,-202.017959595,\-28.771762848,-7.683309555,10.745590210,\-568.485290527,972.520690918,-20.000000000);bg white;as sphere, hollow_%s;color cyan, hollow_%s;ray;save urei%s.png' " % (i, i, i, i, i, i, i)
os.system(pml_cmd)
#remove = "rm urei%s.pdb hollow_%s.pdb" % (i, i)
#os.system(remove)
os.chdir("../")
Run Code Online (Sandbox Code Playgroud)
我运行这个,我得到这个错误:
TypeError Traceback (most recent call last)
<ipython-input-8-53cd3e7bd107> in <module>()
7 os.system(comando)
8 pml_cmd = …Run Code Online (Sandbox Code Playgroud) 我正在尝试在10x10的网格中写入包含多个图像(100)的文件。我使用3进行迭代以:
-打开文件-设置坐标(i,j)
问题是当我查看文件时,只能看到最后一张图像多次。也许每次程序进入for循环时文件都会被覆盖。到目前为止,我找不到解决方案。
代码是:
import Image
from os import listdir
from os.path import isfile, join
files = [ f for f in listdir("/mnt/hgfs/Documents/Notebooks/test1/") if isfile(join("/mnt/hgfs/Documents/Notebooks/test1/", f)) ]
new_im = Image.new('RGB', (3000,3000))
for i in xrange(0,3000,300):
for j in xrange(0,3000,300):
for ima in files:
#paste the image at location i,j:
im = Image.open(ima)
im.thumbnail((300,300))
new_im.paste(im, (i,j))
new_im.save("hola.png")
Run Code Online (Sandbox Code Playgroud)
谢谢!