C:\Users\Jeffery1u>python Python 3.7.3 (default, Mar 27 2019, 17:13:21) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32 Warning: This Python interpreter is in a conda environment, but the environment has not been activated. Libraries may fail to load. To activate this environment please see https://conda.io/activation Type "help", "copyright", "credits" or "license" for more information. >>> 23+7 30 >>> 4**2 16 >>> result=20 >>> print(result) 20 >>> x=30 >>> x+=70 >>> x 100 >>> int(4.3) 4 >>> float(10) 10.0 >>> round(4.67) 5 >>> # i love u ... x=30 >>> x 30 >>> type(x) <class ‘int‘> >>> str=‘i love u‘ >>> str ‘i love u‘ >>> # 使用双引号开始字符串,单引号开始内部字符串 ... str="i love ‘u‘" >>> str "i love ‘u‘" >>> print(str) i love ‘u‘ >>> str=‘‘‘i‘m love "u" ‘‘‘ >>> print(str) i‘m love "u" >>> #上面也可以使用三引号 ... #使用加号字符串 ... pring("a"+"b") Traceback (most recent call last): File "<stdin>", line 3, in <module> NameError: name ‘pring‘ is not defined >>> print("a"+"b") ab >>> "a"+"b"
原文:https://www.cnblogs.com/theDataDigger/p/10728211.html