目录
关于仅需输入一行的内容
1.字符串
2.字符组
3.多个数字
4.一组数(输入形成列表)
关于需输入多行的内容
1.字符串
2.字符组
3.一个数
4.多个数
关于输出内容
1.一个数
2.一维列表
3.二维列表
关于仅需输入一行的内容
1.字符串
s = input()
s = input()
同理我们可以推得关于单个数字的输入
n = int(input())
2.字符组
a = [i for i in input()]
效果如下:
输入:abcdefg 输出:['a', 'b', 'c', 'd', 'e', 'f', 'g']
3.多个数字
a, b, c = map(int, input().split())
4.一组数(输入形成列表)
lst = list(map(int, input().split()))
lst = list(map(int, input().split()))
效果如下:
>> 3 4 11 9 0 1 >> [3, 4, 11, 9, 0, 1]
关于需输入多行的内容
1.字符串
n = int(input())
a = [input() for _ in range(n)]
效果如下:
>> 3 >> hello world >> welcome >> python >> ['hello world', 'welcome', 'python']2.字符组
n = int(input()) lst = [[i for i in input()] for _ in range(n)]
效果如下:
>> 3 >> hello >> abc >> def >> [['h', 'e', 'l', 'l', 'o'], ['a', 'b', 'c'], ['d', 'e', 'f']]
3.一个数
n = int(input())
lst = [int(input()) for _ in range(n)]
效果如下:
>> 3 >> 3 >> 4 >> 5 >> [3, 4, 5]
4.多个数
n = int(input())
lst = [list(map(int, input().split())) for _ in range(n)]
效果如下:
>> 3 >> 11 22 33 >> 44 55 66 8 >> 0 9 67 >> [[11, 22, 33], [44, 55, 66, 8], [0, 9, 67]]
关于输出内容
1.一个数
print(n)
2.一维列表
for i in range(n):
print(lst[i])
3.二维列表
for i in range(n):
for j in range(m):
print(lst[i][j])
print(n)
2.一维列表
for i in range(n):
print(lst[i])
3.二维列表
for i in range(n):
for j in range(m):
print(lst[i][j])
for i in range(n):
for j in range(m):
print(lst[i][j])



