tile函数位于python模块 numpy.lib.shape_base中,他的功能是重复某个数组。比如tile(A,n),功能是将数组A重复n次,构成一个新的数组,我们还是使用具体的例子来说明问题:

先来引入numpy下的所有方法:

>>> from numpy import *

我们创建一个a,如图下图,使用tile来创建b,注意看b的数据结构:

>>> a=[0,1,2]
>>> b=tile(a,2)
>>> b
array([0, 1, 2, 0, 1, 2])

假如我们输入一个元组(1,2),我们会得到一样的结果,与上面相同的b

>>> b=tile(a,(1,2))
>>> b
array([[0, 1, 2, 0, 1, 2]])

当然,我们想要a变为一个二维数组,就要换一种重复的方式了。

>>> b=tile(a,(2,1))
>>> b
array([[0, 1, 2],
[0, 1, 2]])

python tile函数用法的更多相关文章

  1. Python回调函数用法实例详解

    本文实例讲述了Python回调函数用法.分享给大家供大家参考.具体分析如下: 一.百度百科上对回调函数的解释: 回调函数就是一个通过函数指针调用的函数.如果你把函数的指针(地址)作为参数传递给另一个函 ...

  2. python之函数用法setdefault()

    # -*- coding: utf-8 -*- #python 27 #xiaodeng #python之函数用法setdefault() #D.get(k,d) #说明:k在D中,则返回 D[K], ...

  3. python之函数用法fromkeys()

    # -*- coding: utf-8 -*- #python 27 #xiaodeng #python之函数用法fromkeys() #fromkeys() #说明:用于创建一个新字典,以序列seq ...

  4. python之函数用法get()

    # -*- coding: utf-8 -*- #python 27 #xiaodeng #python之函数用法get() #http://www.runoob.com/python/att-dic ...

  5. python之函数用法capitalize()

    # -*- coding: utf-8 -*- #python 27 #xiaodeng #python之函数用法capitalize() #capitalize() #说明:将字符串的第一个字母变成 ...

  6. python之函数用法isupper()

    # -*- coding: utf-8 -*- #python 27 #xiaodeng #python之函数用法isupper() #http://www.runoob.com/python/att ...

  7. python之函数用法islower()

    # -*- coding: utf-8 -*- #python 27 #xiaodeng #python之函数用法islower() #http://www.runoob.com/python/att ...

  8. python之函数用法startswith()

    # -*- coding: utf-8 -*- #python 27 #xiaodeng #python之函数用法startswith() #http://www.runoob.com/python/ ...

  9. python之函数用法endswith()

    # -*- coding: utf-8 -*- #python 27 #xiaodeng #python之函数用法endswith() #http://www.runoob.com/python/at ...

随机推荐

  1. java反射机制(基础版)

    package com.reflect; import java.lang.reflect.Constructor; import java.lang.reflect.Field; import ja ...

  2. jquery plug-in DataTable API中文文档参考

    前言:最近在做一个WEB后台,无意中发现这个插件,试用了一下觉得不错,但网上关于它的资料大多不全,所以利用一些时间将其API文档翻了一下,发在园子里供大家参考.(p.s:个人E文水平很差,对着灵格斯翻 ...

  3. 使用xshell链接本地虚拟机中的Linux

    昨天想在自己机器上安装一下Linux,并使用xshell访问,可是费了很长时间,在xshell端都提示“Could not connect to '192.168.54.100' (port 22): ...

  4. Case 架构的实际应用-2

    Test Plan in TestLink 1. For new release, we will create 2 test plans for each project 2. 1st test p ...

  5. 上下左右布局(DIV+CSS)

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  6. Codeforces Round #272 (Div. 2) C. Dreamoon and Sums (数学 思维)

    题目链接 这个题取模的时候挺坑的!!! 题意:div(x , b) / mod(x , b) = k( 1 <= k <= a).求x的和 分析: 我们知道mod(x % b)的取值范围为 ...

  7. 【笨嘴拙舌WINDOWS】tagTEXTMETRIC结构

    tagTEXTMETRIC用于定义在window输出文字时字的大小,其结构如下: 我在窗体上写了两句话,来详细解剖该结构(在MM_TEXT模式下输出) tmHeight表示一行文字的高度.改例中值为1 ...

  8. UVa 11100 The Trip, 2007

    今天的教训:做题要用大块的时间来做,上午做一下,做题做到一半就去忙别的事,那么后面再做的时候就无限CE,WA了.因为你很难或者需要很长时间来找回当时的思路. 题意:就像套瓷娃娃一样,有n个包,大小可能 ...

  9. 51nod1274 最长递增路径

    将边排序后dp一下就可以了. #include<cstdio> #include<cstring> #include<cctype> #include<alg ...

  10. Context上下文对象(抄书的)

    Servlet上下文 ServletContext 上下文接口    ServletContext接口    每一个应用都有唯一的一个上下文对象,即为ServletContext对象    Servl ...