python 输出自然数数组
时间: 2024-02-02 20:38:28 浏览: 123
Python Numpy 自然数填充数组的实现
Sure, you can use a loop and the print function to output a natural number array in Python. Here's an example code:
```
n = 10 # define the length of the array
arr = [] # create an empty list for the array
# generate the natural number array
for i in range(1, n+1):
arr.append(i)
# print the array
print(arr)
```
This code will output `[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]` as the natural number array.
阅读全文