运用input函数搜集信息

input()函数结果的赋值
name = input('请输入你的名字:') #将input()函数的执行结果(收集的信息)赋值给变量name

input()函数的使用场景
1.函数结果赋值 name=input()
2.搜集信息 name=input(xxx)
3.输出结果 print(name)
——————————————————————————————————
input()函数的数据类型
input()函数的输入值(搜集到的回答),永远会被【强制性】地转换为【字符串】类型

choice = input('请输入1或2:')
print(type(choice))
<class 'str'>

—————————————————————————————————————
input()函数结果的强制转换

choice = int(input('请输入您的选择:'))
#将输入值强制转换为整数,并赋值给变量choice

Python【input()函数】的更多相关文章

  1. Python input() 函数

    Python3.x 中 input() 函数接受一个标准输入数据,返回为 string 类型. Python2.x 中 input() 相等于 eval(raw_input(prompt)) ,用来获 ...

  2. 16.Python input()函数:获取用户输入的字符串

    input() 函数用于向用户生成一条提示,然后获取用户输入的内容.由于 input() 函数总会将用户输入的内容放入字符串中,因此用户可以输入任何内容,input() 函数总是返回一个字符串. 例如 ...

  3. python——input()函数

    在使用input()内置函数输入数字时,要注意一点: input()的返回值始终是字符串,所以type(number)永远是<class 'str'>! 如: >>> t ...

  4. Python input函数使用

    本文链接:https://www.cnblogs.com/zyuanlbj/p/11905475.html 函数定义 def input(*args, **kwargs): # real signat ...

  5. python input函数

    函数 input() 让程序暂停运行,等待用户输入值,之后再把值赋给变量,输出.

  6. input函数出现的问题(Python)

    参考书<A Learner's Guide to Programming Using the Python Language>,写下如下的程序: # coding=utf-8 # 以上是为 ...

  7. Python中的print、input函数以及Python中交换两个变量解析

    一.Python中的值交换操作 首先明确一点点,Python中的一切都是面向对象的,可以理解为Python的中一切都是对象. 我们知道Java也是面向对象的语言,但是在Java中定义一个值变量如下: ...

  8. python input 与raw_input函数的区别

    转自:http://blog.csdn.net/sruru/article/details/7790436 以前没有深入考虑过raw_input与input函数的区别,所以一直比较困惑,今天测试之后, ...

  9. python中子进程不支持input()函数输入

    错误的源代码: import socketimport threadingimport multiprocessing# 创建socketserve_socket = socket.socket(so ...

  10. Python input和print函数

    一.input函数 可以看出,input()函数默认输入的是字符串类型,需要eval()函数将其进行转换. 区别直接赋值的情况,Python可以自动识别数据类型 二.print函数 1.直接输出 无论 ...

随机推荐

  1. Simplifying Failures

    # # Finish the delta debug function ddmin # import re def test(s): print s, len(s),repr(s) if re.sea ...

  2. Python: 在CSV文件中写入中文字符

    0.2 2016.09.26 11:28* 字数 216 阅读 8053评论 2喜欢 5 最近一段时间的学习中发现,Python基本和中文字符杠上了.如果能把各种编码问题解决了,基本上也算对Pytho ...

  3. variant变异 | Epigenome表观基因组 | Disease-susceptible gene 疾病易感基因

    paper:cepip: context-dependent epigenomic weighting for prioritization of regulatory variants and di ...

  4. hive匹配中文

    select regexp_extract('ab中文123测试55..', '[\u4e00-\u9fa5]+', 0) 只提出成功第一段中文汉字,结果为: 中文 select regexp_rep ...

  5. springMVC Controller 参数映射

    springMVC 对参数为null或参数不为null的处理 - 小浩子的博客 - CSDN博客https://blog.csdn.net/change_on/article/details/7664 ...

  6. Dart泛型

    /* 通俗理解:泛型就是解决 类 接口 方法的复用性.以及对不特定数据类型的支持(类型校验) */ //只能返回string类型的数据 // String getData(String value){ ...

  7. Python不带参数的类装饰器

    # -*- coding: utf-8 -*- # author:baoshan # 不带参数的类装饰器 # 类装饰器的实现,必须实现__call__和__init__两个内置函数. # __init ...

  8. asp乱码问题

    UTF-8编码的话:在ASP脚本顶部加入<%@Language="vbscript" Codepage="65001"%>以及再在<head& ...

  9. 011-JSON、JSONObject、JSONArray使用、JSON数组形式字符串转换为List<Map<String,String>>的8种方法

    一.JSON数据格式 1.1.常用JSON数据格式 1.对象方式:JSONObject的数据是用 { } 来表示的, 例如: { "id" : "123", & ...

  10. spring-data-redis数据类型

    一.引入依赖 <!-- 缓存 --> <dependency> <groupId>redis.clients</groupId> <artifac ...