循序渐进学Python2变量与输入
2017-04-20 13:36
330 查看
新建一个test.py文件,右键选择“Edit with IDLE”,编辑完成后,Ctrl+S保存,然后按下F5就可以执行代码了。
注:IDLE是Python官方提供的一个IDE工具。
输出:
输出:
输出:
输出:
或
输出:
注:IDLE是Python官方提供的一个IDE工具。
目录[隐藏]1 注释 2 数字 3 变量 4 输入用法 |
[编辑]注释
#This is a comment
print"This will run."#comment
多行注释使用三个单引号(''')或三个双引号(""")。
[编辑]数字
print 25 + 30 / 6
print"Is it true that 3+2 < 5-7?"
print 3+2<5-7
输出:
30 Is it true that 3+2<5-7? False
[编辑]变量
cars =100
print"There are", cars,"cars available."
输出:
There are 100 cars available.
my_name ="Lei Jun" your_name ="Jobs"
print"Let's talk about", my_name print"Let's talk about %s and %s." % (my_name, your_name)
输出:
Let's talk about Lei Jun Let's talk about Lei Jun and Jobs.
[编辑]输入用法
print"How old are you?" age =raw_input()
print"You're %s old."% age
输出:
How old are you? 27 You're 27 old.
或
age =raw_input("How old are you?")
print"You're %s old."% age
输出:
How old are you?38 You're 38 old.
相关文章推荐
- 循序渐进学Python2变量与输入
- python3 输入多个变量
- python 变量输入
- python程序设计 第二章:核心对象 变量和输入和输出
- python 预设命令行变量代替raw_input 二次输入的方法
- python中变量的输入与输出
- python | 变量与数据 | 字符串转义 | 多行输入
- [Python爬虫] 中文编码问题:raw_input输入、文件读取、变量比较等str、unicode、utf-8转换问题
- python将多个变量输入到文件
- python学习(4)———变量和命名以及输入
- python 变量,数据类型,用户输入输出,流程控制,循环
- Python3.5实战教程(变量/输入/循环)001
- python 变量输入
- 循序渐进Python3(六) -- 初识内置变量、反射、递归
- win10设置环境变量,命令行下输入python,pip可运行
- Python入门(二)——IDE选择PyCharm,输入和输出,基础规范,数据类型和变量,常量,字符串和编码,格式化
- [Python] 中文编码问题:raw_input输入、文件读取、变量比较等str、unicode、utf-8转换问题
- python_基础总结1 python由来 字符编码 注释 pyc文件 python变量 导入模块 获取用户输入 流程控制if while
- Python基础:数据类型、变量定义、输入/输出、逻辑、函数/模块(导入)/类、异常处理
- Python入门(二)——IDE选择PyCharm,输入和输出,基础规范,数据类型和变量,常量,字符串和编码,格式化