Python input()
在Python语言中,我们经常需要与用户实现交互,下面是一个小实例
# -*- coding:UTF-8 -*-
#获取输入参数,并将输入的值存储到txt文件中
String1 = input("Enter The Value of String1:")
String2 = input("Enter The Value of String2:")
f = open(r'D:\python\File\Pra_Q.txt','w') try:
f.write(String1)
f.write('\n')
f.write(String2) finally:
f.close()
上述代码实现功能为:用户输入2个字符串,然后将这两个字符串存储到文件Pra_Q.txt中
执行结果:

在Python 3.5.2中raw_input()变成了input()
>>> raw_input_A=raw_input("Enter the var:")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'raw_input' is not defined
>>> raw_input_A=input("Enter the var:")
Enter the var:
Python input()的更多相关文章
- Python input 和 raw_input的区别
转载[http://www.pythonclub.org/python-basic/input] 使用input 和 raw_input 都可以读取控制台的输入,但是input和raw_input在处 ...
- 【每日一个小技巧】Python | input的提示信息换行输出,提示信息用变量表示
[每日一个小技巧]Python | input的提示信息换行输出,提示信息用变量表示 在书写代码的途中,经常会实现这样功能: 请输入下列选项前的序号: 1.选择1 2.选择2 3.选择3 在pytho ...
- Python input 使用
Python 3.0 中使用"input" , Python 2.0 中使用"raw_input"Python 3.5: #!C:\Program Files\ ...
- python input() 与 raw_input()
使用input和raw_input都可以读取控制台的输入,但是input和raw_input在处理数字时是有区别的 当输入为纯数字时: input返回的是数值类型,如int,floatraw_inpo ...
- python input选择
例1 import sys #声明字符串数组并初始化 newspaper=['1.北京晚报','2.作家文摘','3.参考消息', \ '4.证券报','5.不需要'] #字符串数组的输出 ): pr ...
- python input 与raw_input函数的区别
转自:http://blog.csdn.net/sruru/article/details/7790436 以前没有深入考虑过raw_input与input函数的区别,所以一直比较困惑,今天测试之后, ...
- nyoj 259-茵茵的第一课 (python, input, print)
259-茵茵的第一课 内存限制:64MB 时间限制:3000ms 特判: No 通过数:23 提交数:36 难度:0 题目描述: 茵茵今年已经六年级了,爸爸给她报了一个学习程序设计的班. 第一节课上, ...
- Python input() 函数
Python3.x 中 input() 函数接受一个标准输入数据,返回为 string 类型. Python2.x 中 input() 相等于 eval(raw_input(prompt)) ,用来获 ...
- Python input/output boilerplate for competitive programming
The following code is my submission for Codeforces 1244C The Football Season. import io import sys i ...
随机推荐
- 如何去掉有背景图的a标签的边框
有两种情况: 1.<a href="#" style="background:url(../images/download.png);"></ ...
- Oracle对表解锁的操作
1.查出被锁的表 SELECT lpad(' ',decode(l.xidusn ,0,3,0))||l.oracle_username User_name, o.owner,o.object_na ...
- typedef 与define 的区别
typedef和#define的用法与区别 typedef和#define的用法与区别 一.typedef的用法 在C/C++语言中,typedef常用来定义一个标识符及关键字的别名,它是语言编译 ...
- CRC校验代码实现
1.CRC校验简介 CRC就是块数据的计算值,它的全称是“Cyclic Redundancy Check”,中文名是“循环冗余码”.CRC校验是数据通讯中最常采用的校验方式.在嵌入式软件开发中,经常要 ...
- Duilib学习笔记《05》— 消息响应处理
在Duilib学习笔记<04>中已经知道了如何将窗体显示出来,而如何处理窗体上的事件.消息呢? 一. 系统消息 窗体显示的时候我们就已经说了,窗体是继承CWindowWnd类的,对于窗体的 ...
- JSON时间转换格式化
通常JSON时间一般是这样的格式. 1 /Date(1436595149269)/ 通常我们用AJAX获取下来的JSON数据,如果有时间,都是这种格式的.其中,中间的一段数字"1436595 ...
- HiveSQL解析过程详解 | 学步园
HiveSQL解析过程详解 | 学步园 http://www.xuebuyuan.com/2210261.html
- Symantec System Recovery
目的:备份系统,备份文件,裸机恢复,异机恢复等 工具:http://bbs.kafan.cn/thread-1800182-1-1.html 下载地址:http://pan.baidu.com/s/1 ...
- Longest Common Prefix [LeetCode 14]
1- 问题描述 Write a function to find the longest common prefix string amongst an array of strings. 2- 思路 ...
- 设计模式-原型模式(Prototype)
场景分析: 前面我们提到,交易对象Trade,还有继承他的债券交易BondTrade.期货交易FutureTrade. 现在有一个需求,需要提供方法将交易拆分成多笔小交易. 代码如下(如果没有clon ...