Mảng python lặp lại n lần

cục mịch. lặp lại () trong Python

Cải thiện bài viết

Lưu bài viết

Thích bài viết

  • Cập nhật lần cuối. 28 tháng 3 năm 2022

  • Đọc
  • Bàn luận
  • khóa học
  • Luyện tập
  • Băng hình
  • Cải thiện bài viết

    Lưu bài viết

    các numpy. hàm repeat() lặp lại các phần tử của mảng – arr. cú pháp.  

    numpy.repeat(arr, repetitions, axis = None)

    Thông số.  

    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.

    Trở lại.  

    An array with repetitions of array - arr elements as per repetitions, number of times 
    we want to repeat arr  

    mã 1.  

    con trăn




    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    1

    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    2

     

    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    3
    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    4

     

    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    5

    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    0
    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    1
    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    2
    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    3
    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    4

    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    5
    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    6

     

    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    7____11
    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    9

    An array with repetitions of array - arr elements as per repetitions, number of times 
    we want to repeat arr  
    0
    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    1
    An array with repetitions of array - arr elements as per repetitions, number of times 
    we want to repeat arr  
    2

    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    5
    An array with repetitions of array - arr elements as per repetitions, number of times 
    we want to repeat arr  
    4
    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    9
    An array with repetitions of array - arr elements as per repetitions, number of times 
    we want to repeat arr  
    6

    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    5
    An array with repetitions of array - arr elements as per repetitions, number of times 
    we want to repeat arr  
    8

     

    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    7____11
    An array with repetitions of array - arr elements as per repetitions, number of times 
    we want to repeat arr  
    41

    An array with repetitions of array - arr elements as per repetitions, number of times 
    we want to repeat arr  
    0
    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    1
    An array with repetitions of array - arr elements as per repetitions, number of times 
    we want to repeat arr  
    2

    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    5
    An array with repetitions of array - arr elements as per repetitions, number of times 
    we want to repeat arr  
    4
    An array with repetitions of array - arr elements as per repetitions, number of times 
    we want to repeat arr  
    41
    An array with repetitions of array - arr elements as per repetitions, number of times 
    we want to repeat arr  
    6

    An array with repetitions of array - arr elements as per repetitions, number of times 
    we want to repeat arr  
    49

    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    30

    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    5
    An array with repetitions of array - arr elements as per repetitions, number of times 
    we want to repeat arr  
    8

    đầu ra.  

    An array with repetitions of array - arr elements as per repetitions, number of times 
    we want to repeat arr  
    4

    mã 2.  

    con trăn




    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    1

    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    2

     

    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    3
    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    4

     

    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    0
    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    1
    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    2
    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    10
    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    11
    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    9
    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    13
    An array with repetitions of array - arr elements as per repetitions, number of times 
    we want to repeat arr  
    41
    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    4

    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    5
    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    6

     

    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    7____11
    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    9

    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    5
    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    22
    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    23
    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    24

    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    5
    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    26

     

     

    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    7____11
    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    9

    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    5
    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    22
    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    32
    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    24

    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    5
    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    26

    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    36

    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    7____11
    An array with repetitions of array - arr elements as per repetitions, number of times 
    we want to repeat arr  
    41

    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    5
    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    22
    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    23
    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    24

    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    5
    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    26

    đầu ra.  

    array       : [array_like]Input array. 
    repetitions : No. of repetitions of each array elements along the given axis.
    axis        : Axis along which we want to repeat values. By default, it returns 
               a flat output array.
    3

    Tham khảo. https. // tài liệu. scipy. org/doc/numpy/tham chiếu/được tạo/numpy. nói lại. htmlLưu ý. Các mã này sẽ không chạy trên IDE trực tuyến. Vui lòng chạy chúng trên hệ thống của bạn để khám phá hoạt động. Bài viết này được đóng góp bởi Mohit Gupta_OMG 😀 . Nếu bạn thích GeeksforGeeks và muốn đóng góp, bạn cũng có thể viết một bài báo bằng cách sử dụng write. chuyên viên máy tính. org hoặc gửi bài viết của bạn tới review-team@geeksforgeeks. tổ chức. Xem bài viết của bạn xuất hiện trên trang chính của GeeksforGeeks và trợ giúp các Geeks khác. Vui lòng viết bình luận nếu bạn thấy bất cứ điều gì không chính xác hoặc bạn muốn chia sẻ thêm thông tin về chủ đề thảo luận ở trên.


    Ghi chú cá nhân của tôi arrow_drop_up

    Tiết kiệm

    Vui lòng Đăng nhập để nhận xét.