print()函数
无引号(计算机读懂括号内容,打印最终结果
)
print(1234)
单引号用法(计算机无需理解,原样复述引号中的内容
)
print('小艾')
双引号用法(计算机无需理解,原样复述引号中内容,可以输出内容中的单引号
)
print("小艾")
print("I'm role")
三引号用法(实现换行
)
print('''今天,
天气真好,
一起出去溜达吧''')
另一种方法实现换行,就是使用转义字符 \n
print('今天,\n天气真好,\n一起出去溜达吧')
除了 \n
之外,还有其他的转义字符,比如:
转义字符 | 意义 |
---|---|
\a | 响铃(BEL) |
\b | 退格(BS),将当前位置移到前一列 |
\f | 换页(FF),将当前位置移动到下页开头 |
\n | 换行(LF),将当前位置移到下一行开头 |
\r | 回车(CR),将当前位置移到本行开头 |
\t | 水平制表(HT) (跳到下一个TAB位置) |
\v | 垂直制表(VT) |
\0 | 空字符(NUL) |
\' | 代表一个单引号(撒号)字符 |
\'' | 代表一个双引号字符 |
\? | 代表一个问号 |
\\ | 代表一个单斜线字符 |
\xhh | 1到2位十六进制所代表的任意字符 |
\ddd |
变量命名规范
只能包含数字、字母和下划线
不能以数字开头
尽量描述包含的数据内容
name = '哪吒'
name = '三太子'
print(name)
变量的最终值等于最后复制的结果
除了变量名之外,"="不是等于的意思,而是赋值, 表示把 = 号右边的内容放进左边的变量。==才是等于的意思。
数据类型
字符串(str):用引号括起来的文本
整型(int):整数数字
浮点数(float):带小数点的纯数字
python算术运算符
运算符 表示 例子 +
加 10+2输出结果12 -
减 10-2输出结果8 *
乘 10*2输出结果20 /
除 10/2输出结果5
数据拼接
方法
:用"+"号将数据进行拼接目的
:数据整合数据类型查询--type()函数
作用
:查询数据类型示例:print(type('查询的内容'))
数据结构转换
- int 转 str
- str 转 int (
文字类型和小数类的字符串,不能转换成int
) - int 转 float
- float 转 int (
抹零取整
) - float 转 str
str 转 float (
文字类型不能转换成float
)举例说明上面文字叙述
例子1
num1 = 1 num2 = 2 name1 = '囚犯' name2 = 'CA' word1 = '你有什么能力来带我们出去?' word2 = '我揍了希特勒200多次' fuhao1 = ':' print(str(num1) + name1 + fuhao1 + word1) print(str(num2) + name2 + fuhao1 + word2)
例子2
name = '美国队长' num = '2.5' word = '该片于2014年4月4日在北美与中国同步上映。' print(name + str(int(float(num))) + word)
单向判断:
if
# 为钱包赋值
money = 3000
# 条件:如果有3000块钱以上(包含3000块),就去吃火锅
if money>=3000:
# 结果:显示‘你去吃火锅’的结果
#【注:缩进是四个空格或一个 Tab 键,且Tab 键和四个空格不能混用,千万注意!千万注意!】
print('小明带小红去吃火锅')
双向判断:if...else...
if…else…其实就是二选一,满足条件执行 if 里面的代码块,不满条件执行 else 代码块。
# 为钱包赋值 money = 500 # 条件:如果有1000块钱以上(包含1000块),就去吃日料 if money>=1000: print('金刚狼带凤凰女去吃日料') # 条件:当不满足if条件,执行else条件下语句 else: print('金刚狼带凤凰女去吃KFC')
多向判断:
if...elif...else...
# 条件:如果有1000块钱以上(包含1000块),就去吃日料 if money>=1000: print('金刚狼带凤凰女去吃日料') # 条件:如果有800-1000块钱之间(包含800块) elif money>=800: print('金刚狼带凤凰女去吃披萨') #不满足条件 else: print('金刚狼带凤凰女去吃KFC')
3 comments
激活后如果显示key is invalid,这是因为你破解过软件的原因,请按如下操作
打开软件,help edit VM options ,删掉最下面一行的javaagent,重启软件即可
2018.1以下版本
NTX8Y78G2Z-eyJsaWNlbnNlSWQiOiJOVFg4WTc4RzJaIiwibGljZW5zZWVOYW1lIjoi5rC45LmF5r+A5rS7IHd3d8K3YWppaHVvwrdjb20iLCJhc3NpZ25lZU5hbWUiOiIiLCJhc3NpZ25lZUVtYWlsIjoiIiwibGljZW5zZVJlc3RyaWN0aW9uIjoiIiwiY2hlY2tDb25jdXJyZW50VXNlIjpmYWxzZSwicHJvZHVjdHMiOlt7ImNvZGUiOiJQQyIsInBhaWRVcFRvIjoiMjAyMi0wOS0yNCJ9LHsiY29kZSI6IlBQQyIsInBhaWRVcFRvIjoiMjAyMi0wOS0yNCJ9LHsiY29kZSI6IlBXUyIsInBhaWRVcFRvIjoiMjAyMi0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