美文网首页
python输入input用法

python输入input用法

作者: 混沌游灵 | 来源:发表于2021-10-12 22:38 被阅读0次

基本

Python3 中 input() 函数接受一个标准输入数据,返回为 string 类型

各种情形

1.接收多个变量:

    引入split()函数,因为input输入默认是string,string中常用split来分割不同变量

例:string.split(str="", num=string.count(str))

str是分隔符(默认为所有的空字符,包括空格、换行(\n)、制表符(\t)等),num是分隔次数,返回类型list

     用于input中可如下使用:

str1,str2=input.split()

2.转换类型:

    引用map函数

例:int1,int2=map(int,input().split())

3.矩阵转换:

   m=[list(map(int,input().split())) for i in range(m)] 

其中m为行数

相关文章

  • Python 基本输入输出

    '''输入函数 input()Python中可以使用内置函数 input()接收用户的键盘输入.基本用法:vari...

  • python输入input用法

    基本 Python3 中 input() 函数接受一个标准输入数据,返回为 string 类型 各种情形 1.接收...

  • 2018-08-24 Day5-break 、continue

    break 、continue 、else、print的用法 补充:python控制台输入函数--- input(...

  • dey5 break continue.else.print 的

    break 、continue 、else、print的用法补充:python控制台输入函数--- input()...

  • help帮助

    Python help()内为函数名,如raw_input(),只输入函数名即可用法:help(raw_input...

  • pydoc用法

    注意以下均为终端输入指令 1、作用一:查看函数用法 查看input()函数用法 输入q可退出

  • Python 输入与输出

    输入与输出 输入 python2 raw_input()将用户输入作为'str'赋值给变量input()将用户输入...

  • Python基础

    @贰拾贰画生 感谢简明Python教程 输入输出 输入:raw_input string = raw_input(...

  • 【Python】基础总结

    输入 input("提示性信息") 如:input("请输入数字") 评估函数 因为 Python 没有特别人为规...

  • 第一个python程序

    第一个python程序 输入和输出 1. 输出 2. 输入 (1) input() 小结: 输入是Input,输出...

网友评论

      本文标题:python输入input用法

      本文链接:https://www.haomeiwen.com/subject/gwidxltx.html