python中用#表示注释
在pycharm用ctrl +/可以注释化代码
print "hello",在python2中可以使用,python3中就不可以使用了
print在python2中是一个语法结构,在python3中是内置函数
python支持大数运算
\n 表示换行符
print("hello\n" *2)
hello
hello
python中变量是区分大小写的
要在字符中加入双引号:
1.\"
2.' " '
设计一个简单的小游戏,猜数字:
temp = input("请输入文字")
guess = int(temp) # 这里int函数是用来转化数据类型的
if guess == 8:
print("对的")
else:
print("不对")
print("游戏结束")
内置函数:就是可以直接使用的函数
print()函数,里面的数据类型可以是多种类型(我认为这是比较厉害的地方)
=表示赋值,==表示判断是否相等
int与string类型的比较:
3 == "3"
False
3 > "2"
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
3 > "2"
TypeError: '>' not supported between instances of 'int' and 'str'