小编hku*_*s10的帖子

如何在Python中显示jpg文件?

def show():

    file = raw_input("What is the name of the image file? ")

    picture = Image(file)

    width, height = picture.size()

    pix = picture.getPixels()
Run Code Online (Sandbox Code Playgroud)

我正在尝试编写代码来显示此图像,但此代码不提供图像.如何更改我的代码才能显示此图像?

python

22
推荐指数
2
解决办法
15万
查看次数

如何在python中使用键盘进行复制和粘贴?

此外,是否有任何功能我可以使用键盘来控制,以便更有效地创建程序?

谢谢

python copy-paste

7
推荐指数
1
解决办法
6万
查看次数

如何压缩这个功能?

def average(tup):
  """ ugiufh """
   total = ((int(tup[0]) + int(tup[1]) + int(tup[2]))/3,
            (int(tup[0]) + int(tup[1]) + int(tup[2]))/3,
            (int(tup[0]) + int(tup[1]) + int(tup[2]))/3)
   return total
Run Code Online (Sandbox Code Playgroud)

我正在编写一个函数来平均一个元组中的三个元素,这意味着如果原始元组=(1,2,3)给我元组=(2,2,2)

我的问题是有没有办法压缩写的内容给我相同的答案?如果是的话,如何凝聚它?

谢谢

python

3
推荐指数
1
解决办法
154
查看次数

如何编写一个函数来计算python中2点之间的中点?

def midpoint(p1, p2):
"""
PRE: p1 and p2 are Point objects (from the graphics module)
POST: a new Point equidistant from and co-linear with p1 and p2
is computed and returned
Run Code Online (Sandbox Code Playgroud)

使用以下规范编写函数中点

python

2
推荐指数
3
解决办法
2万
查看次数

标签 统计

python ×4

copy-paste ×1