Python 3.9.7 (tags/v3.9.7:1016ef3, Aug 30 2021, 20:05:41) [MSC v.1929 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> print("D:\12.code")
D:
.code
>>> print("D:\\12.code")
D:\12.code
>>> print(r"D:\12.code")
D:\12.code
>>> # \ 表示还没完 \n 换行符号
>>> print("1\n\
2\n\
3\n")
1
2
3
>>> news = """12345"""
>>> print(news)
12345
>>>
>>> print("我爱你\n"*10)
我爱你
我爱你
我爱你
我爱你
我爱你
我爱你
我爱你
我爱你
我爱你
我爱你
>>>
>>> 1>1
False
>>> 1<2
True
>>> 1>=2
False
>>> 1==1
True
>>> 1!=1
False
>>> 2!=1
True
>>> #判断两个对象的id 是否相等
>>> is
>>> isnot 判断两个对象的 id 是否相不相等
随机数 1-10,100-10000?之间
Alt+p? ?重复上一条语句
Python 3.9.7 (tags/v3.9.7:1016ef3, Aug 30 2021, 20:05:41) [MSC v.1929 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> import random
>>> x = random.getstate()
>>> print(x)
>>> random.randint(1,10)
2
>>> random.randint(1,10)
5
>>> random.randint(1,10)
7
>>> random.setstate(x)
>>> random.randint(1,10)
2
>>> random.randint(1,10)
5
>>> random.randint(1,10)
7
>>> random.randint(1,10)
8
>>> random.randint(1,10)
2
>>> random.randint(1,10)
8
>>> random.randint(1,10)
10
>>> random.randint(1,10)
10
>>>
>>>
>>> import random
>>> random.randint(1,10)
5
>>> random.randint(1,10)
7
>>> random.randint(1,10)
6
>>>
>>> random.randint(100,10000)
888
>>> random.randint(100,10000)
9987
>>> random.randint(100,10000)
6384
|