- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我正在尝试运行这个简单的 Python 代码 (a.py):
# list test
import time
class List(object):
class Cons(object):
def __init__(self, x, tail):
self.x= x
self.tail=tail
class Nil(object):
def __init__(self):
pass
@classmethod
def cons(cls, cons):
return List(cons, None)
@classmethod
def nil(cls, nil):
return List(None, nil)
def __init__(self, cons, nil):
self.cons = cons
self.nil = nil
def replicate(n, x):
return List.nil(List.Nil()) if n == 0 else List.cons(List.Cons(x,replicate(n-1,x)))
t1 = time.time()
List.cons(List.Cons(object(), List.nil(List.Nil())))
t2 = time.time() - t1
print t2
但它不起作用:
$ ./a.py
Version: ImageMagick 6.8.8-10 Q16 x86_64 2014-04-08 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC Modules OpenMP
Delegates: bzlib djvu ltdl png zlib
Usage: import [options ...] [ file ]
Image Settings:
-adjoin join images into a single multi-image file
-border include window border in the output image
-channel type apply option to select image channels
-colorspace type alternate image colorspace
-comment string annotate image with comment
-compress type type of pixel compression when writing the image
-define format:option
define one or more image format options
-density geometry horizontal and vertical density of the image
-depth value image depth
-descend obtain image by descending window hierarchy
-display server X server to contact
-dispose method layer disposal method
-dither method apply error diffusion to image
-delay value display the next image after pausing
-encipher filename convert plain pixels to cipher pixels
-endian type endianness (MSB or LSB) of the image
-encoding type text encoding type
-filter type use this filter when resizing an image
-format "string" output formatted image characteristics
-frame include window manager frame
-gravity direction which direction to gravitate towards
-identify identify the format and characteristics of the image
-interlace type None, Line, Plane, or Partition
-interpolate method pixel color interpolation method
-label string assign a label to an image
-limit type value Area, Disk, Map, or Memory resource limit
-monitor monitor progress
-page geometry size and location of an image canvas
-pause seconds seconds delay between snapshots
-pointsize value font point size
-quality value JPEG/MIFF/PNG compression level
-quiet suppress all warning messages
-regard-warnings pay attention to warning messages
-respect-parentheses settings remain in effect until parenthesis boundary
-sampling-factor geometry
horizontal and vertical sampling factor
-scene value image scene number
-screen select image from root window
-seed value seed a new sequence of pseudo-random numbers
-set property value set an image property
-silent operate silently, i.e. don't ring any bells
-snaps value number of screen snapshots
-support factor resize support: > 1.0 is blurry, < 1.0 is sharp
-synchronize synchronize image to storage device
-taint declare the image as modified
-transparent-color color
transparent color
-treedepth value color tree depth
-verbose print detailed information about the image
-virtual-pixel method
Constant, Edge, Mirror, or Tile
-window id select window with this id or name
Image Operators:
-annotate geometry text
annotate the image with text
-colors value preferred number of colors in the image
-crop geometry preferred size and location of the cropped image
-encipher filename convert plain pixels to cipher pixels
-geometry geometry preferred size or location of the image
-help print program options
-monochrome transform image to black and white
-negate replace every pixel with its complementary color
-repage geometry size and location of an image canvas
-quantize colorspace reduce colors in this colorspace
-resize geometry resize the image
-rotate degrees apply Paeth rotation to the image
-strip strip image of all profiles and comments
-thumbnail geometry create a thumbnail of the image
-transparent color make this color transparent within the image
-trim trim image edges
-type type image type
Miscellaneous Options:
-debug events display copious debugging information
-help print program options
-list type print a list of supported option arguments
-log format format of debugging information
-version print version information
By default, 'file' is written in the MIFF image format. To
specify a particular image format, precede the filename with an image
format name and a colon (i.e. ps:image) or specify the image type as
the filename suffix (i.e. image.ps). Specify 'file' as '-' for
standard input or output.
import: delegate library support not built-in `' (X11) @ error/import.c/ImportImageCommand/1303.
./a.py: line 3: syntax error near unexpected token `('
./a.py: line 3: `class List(object):'
怎么了?是编码问题吗?
最佳答案
您缺少 python shebang,#!/usr/bin/env python
。将此添加为第一行,告诉操作系统将您的文件作为 python 脚本而不是 shell 脚本运行。
或者,运行 python ./a.py
关于python - 尝试运行 Python 脚本时出现令人困惑的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23038549/
我有一个程序可以打开一个窗口并快速改变背景颜色并随机弹出矩形和椭圆形。我的代码有效,但我不知道为什么,因为我没有在我的代码中调用 repaint() 函数。当我使用我个人的 update() 函数包含
var allRapidSpells = $$('input[value^=RSW]'); 谁能告诉我这是做什么的? 最佳答案 我敢猜测您正在使用 MooTools ,一个 JavaScript 框架
我有一个抽象父类,它有多个子类。我希望 child 能够拥有一个对于该 child 的每个实例都相同的变量。我不想将构造函数传递给 child 来告诉它它的名字,因为当它可以被硬编码时,这看起来很愚蠢
我刚刚在 Git 存储库上做了一些糟糕的事情,我不知道如何解决这个问题。我什至不知道我是怎么把它弄成这样的……! 在存储库(托管在 git hub 上)上,有 3 个我感兴趣的分支:master、br
我是 GIT 的新手,在理解提交日志图时遇到问题。 我感觉每条平行线都是一个分支。虽然我的源代码只有 2 个分支。我在下面提供的提交日志图中看到 3-4 条平行线(Microsoft Team Ser
我是 WPF 的新手,ScrollViewer 让我很沮丧。要么我只是没有“得到”它,要么它是一种有限的控制。 这是我的挫折: 水平滚动错误 水平滚动条仅在列表底部可见(我必须滚动到底部才能看到) 坏
那么 $('table.selectable td.capable input:text') 比 $('table.selectable td input:text') 更好吗?换句话说,指定一个类会
我刚刚完成了计算机图形学类(class),我们必须对光线追踪器进行编程。尽管所有结果都是正确的,但我对 OpenMP 的使用感到困惑(顺便说一句,这不是类(class)的一部分)。我有这个循环(C++
与 PatternSynonyms ( explicitly bidirectional form ),pattern-to-expr 方程实际上形成了一个函数,但拼写为大写(假设您最终得到正确类型的
我是 javascript/coffeescript 新手。 有人可以解释一下为什么这个 CoffeeScript/JavaScript 会毫无延迟地快速通过吗?我对第一种情况的想法是,它是对 upd
如果我调用document.getElementsByClassName('cl'),我会得到一个 HTMLCollection。它似乎包含 Element 对象而不是 HTMLElement 对象,
这是我本月的 azure payasyougo 使用费用。 我很难理解为什么我要为标准中型应用服务付费,我认为它会包含在计算时间中?我只运行一个云服务,这对于一个没有做太多事情的云服务来说似乎有点陡峭
除了the issue I am already having之外,我还在I saw a video on it之后安装了HBase(尚未安装)之前,还安装了Zookeeper。在安装它时,我遇到了许
我正在将 XSLT 与 regexp:match exslt 函数一起使用。上述函数采用 JavaScript Regex 模式。因此,我尝试匹配一组数字 1 到 3 OR 5 到 7 OR 9 到
我想知道为什么这段代码会给出消息:SyntaxError:意外的标记其他。 var compare = function(choice1,choice2){ if(choice1===choice2)
我尝试使用复选框和 JQuery 过滤日历上的事件, $(document).ready(function () { $('.scrollable-menu :checkbox').click(f
假设我们有一个用户想要一个名为:“test/lasdhjal.txt”,无论如何。现在,如果我将其放入新的文件(输入)中;对象里面,它会认为 test/是一个文件夹,而它是名称的一部分。我能做什么呢?
问题是 stash 的更改不会留在我 stash 它们的分支中。其他分支存储将被覆盖示例: 我愿意: git checkout iss4 // made some changes gi
我是一个 java 新手,并且在 StackOverflow 错误/在类之间访问文件的能力方面遇到了一个非常令人困惑的问题。我知道根本原因可能是我进行了一些递归调用,但修复它的语法却让我无法理解。我认
public X createData(int n) { int[] values = new int[n]; Random rand = new Random(); for
我是一名优秀的程序员,十分优秀!