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 ...
随机推荐
- SMTP邮件发送命令
第一步,远程登录smtp服务器 在命令行窗口输入 telnet smtp.163.com 25 然后回车第二步,用户登录 输入 helo 163.com 回车,这是向服务器表明你的用户身份250 OK ...
- CI 自动提交表单
//coontrol $this->load->view ( '/' . $this->index_lang ['FOLDER'] . '/eprepag_form.php', $p ...
- Linux下搭建Lotus Domino集群
Linux下搭建Lotus Domino 集群 本文内容是Linux平台下Lotus Domino服务器部署案例(http://chenguang.blog.51cto.com/350944/1334 ...
- 百度地图API示例之添加自定义控件
代码 <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" cont ...
- 获取Spring的上下文环境ApplicationContext的方式
摘自: http://blog.csdn.net/yang123111/article/details/32099329 获取Spring的上下文环境ApplicationContext的方式 Web ...
- javascript之值传递与引用传递
在分析这个问题之前,我们需了解什么是按值传递(call by value),什么是按引用传递(call by reference).在计算机科学里,这个部分叫求值策略(Evaluation Strat ...
- Velocity语法大全
1\ 参考地址:http://www.cnblogs.com/codingsilence/archive/2011/03/29/2146580.html
- 3Git使用入门
1.Git作用:对源代码进行管理: 2.安装Git命令: apt-get install git apt-get install git-doc git-svn git-email git-gui g ...
- Android IOS WebRTC 音视频开发总结(五三)-- 国内IM & RTC SDK列表
本文主要总结国内提供RTC SDK的产品,转载必须说明出处,文章来自博客园RTC.Blacker,欢迎关注微信公众号blacker,更多详见www.rtc.help 自从开通邮件和微信公众号以来,很多 ...
- win7启动文件修复
1:在xp下运行bcdedit.exe(这软件在windows 7的系统盘下 就在你的c:\windows\system32\这里2:将这软件复制到c盘根目录下3:进入命令提示符 输入 c:4:输入 ...