当我尝试使用标题保存矩阵时,第一行会出现哈希标记和空格(#):
输入:
np.savetxt(filename,data, fmt='%i %i %i %i %s',delimiter='\t',header="a\tb\tc\td\te")
Run Code Online (Sandbox Code Playgroud)
输出:
# a b c d e
0 0 0 0 bla
0 0 0 0 bla
1 1 1 1 bla
1 1 1 1 bla
Run Code Online (Sandbox Code Playgroud)
任何暗示为什么?我怎么能删除它?
我正在尝试运行此代码,对我拥有的每一帧运行相同的命令(几乎没有变化):
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) 问题中的一般术语(与专业相反)意味着函数可以对项目进行排序,只要它们是一个类型的实例Ord.
考虑一个最着名的haskell广告
quicksort :: Ord a => [a] -> [a]
quicksort [] = []
quicksort (p:xs) = (quicksort lesser) ++ [p] ++ (quicksort greater)
where
lesser = filter (< p) xs
greater = filter (>= p) xs
Run Code Online (Sandbox Code Playgroud)
上述实施不是就地.
我试图写一个就地版本.就地快速进行快速排序很容易.通常,我们只需要一个可变数组,我选择了Foreign.Marshal.Array.
我的实现是就地并运行得很好,但我对它的类型签名不满意
(Ord a, Storable a) => [a] -> IO [a]
Run Code Online (Sandbox Code Playgroud)
更确切地说,类型约束Storable a使我恼火.
显然,如果我们想要对项目进行排序,Ord则需要约束,而不Storable需要.
相比之下,经典的快速排序的类型或者签名sort的Data.List,是Ord a => [a] -> [a].约束只是Ord. …
我想在pygame中显示一个游戏.但它出于某种原因,任何想法都不会起作用?这是我的代码:
import pygame, sys
from pygame.locals import *
pygame.init()
screen=pygame.display.set_mode((640,360),0,32)
pygame.display.set_caption("My Game")
p = 1
green = (0,255,0)
pacman ="imgres.jpeg"
pacman_x = 0
pacman_y = 0
while True:
pacman_obj=pygame.image.load(pacman).convert()
screen.blit(pacman_obj, (pacman_x,pacman_y))
blue = (0,0,255)
screen.fill(blue)
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
if event.type==KEYDOWN:
if event.key==K_LEFT:
p=0
pygame.display.update()
Run Code Online (Sandbox Code Playgroud)