输入函数

1 input()

# input()函数输入的任何量都会转为str类型,所以要映射为int
l,r=map(int,input().split())
print(l, r, type(l))
# 输入 1 2
# 1 2 <class 'int'>
View Code

2 sys.stdin.readline()

# 同input一样默认输入的格式是字符串
import sys
# line1 = sys.stdin.readline()        # 包含换行符"
"
line1 = sys.stdin.readline().strip()  # strip()默认去掉换行符"
"
line2 = input()  # 不包含换行符"
"
print(len(line1), len(line2))
# aaa
# bbb
# 3 3
View Code

ttt

原文地址:https://www.cnblogs.com/xxswkl/p/12130286.html