随笔分类 - python
摘要:>>> 5 > 3 and 5 > 4 True >>> 5 > 3 and 5 > 6 False >>> 5 > 3 or 5 < 4 True >>> 5 > 7 or 5 > 6 False >>> not 0 True >>> not 1 False >>> not 2 False >>>
阅读全文
摘要:>>> 3 > 5 False >>> 3 >= 5 False >>> 3 < 5 True >>> 3 == 5 False >>> 3 != 5 True >>> 3 <= 5 True
阅读全文
摘要:>>> a = 5 >>> a 5 >>> type(a) <class 'int'> >>> b = float(a) >>> b 5.0 >>> type(b) <class 'float'> >>> c = 5.3 >>> c 5.3 >>> type(c) <class 'float'> >
阅读全文
摘要:>>> a = "line1\nline2\nline3\nline4\n……" >>> print(a) line1 line2 line3 line4 …… >>> a = """line1 ## 使用"""xxxx""" 可以省略\n. line2 line3 line4 …… """ >>>
阅读全文
摘要:>>> a = "ab\ncde" >>> print(a) ab cde >>> b = "ab\\ncde" >>> print(b) ab\ncde >>> c = r"ab\ncd3" >>> print(c) ab\ncd3
阅读全文
摘要:>>> int(3) 3 >>> int(3.1) 3 >>> int(3.5) 3 >>> int(3.7) 3 >>> int(3.9) 3
阅读全文
摘要:>>> 5 % 0 Traceback (most recent call last): File "<pyshell#354>", line 1, in <module> 5 % 0 ZeroDivisionError: integer division or modulo by zero >>>
阅读全文
摘要:>>> 3 / 2 ## 普通除法,保留浮点 1.5 >>> 3 // 2 ## 地板除法,省略小数点 1
阅读全文
摘要:>>> a = 8 >>> type(a) <class 'int'> ## 整数 >>> b = "xxx" >>> type(b) <class 'str'> ## 字符串 >>> c = True >>> type(c) <class 'bool'> ## 布尔型 >>> d = ["aaa"
阅读全文
摘要:1、报错信息 2、安装libffi-devel [root@linuxprobe Python-3.9.1]# yum install libffi-devel Updating Subscription Management repositories. Unable to read consume
阅读全文
摘要:>>> a = 5 >>> print(a) 5 >>> b = 7 >>> print(b) 7 >>> c = 9 >>> print(c) 9 >>> a,b,c = 4,0,3 ## 同时给多个变量赋值 >>> print(a) 4 >>> print(b) 0 >>> print(c) 3
阅读全文
摘要:>>> 2 * 3 6 >>> 2 ** 3 ## 表示2的3次方 8 >>> 10 ** 5 ## 10的5次方 100000 >>> 2 + 3 * 3 ## python默认运算顺序 11 >>> (2 + 3) * 3 # 改变运算顺序 15 >>> "a" * 3 'aaa' >>> pr
阅读全文
摘要:>>> a = "string1" >>> b = "string2" >>> print(ab) ## 直接输出报错 Traceback (most recent call last): File "<pyshell#33>", line 1, in <module> print(ab) Name
阅读全文
摘要:>>> test1 = " string " ## 两边均为空格 >>> test1.rstrip() ## 删除右边空格,r为right ' string' >>> test1.lstrip() ## 删除左边空格,l为left 'string ' >>> test1.strip() ## 同时删
阅读全文
摘要:1、 >>> value = "good MORNING" ## 定义变量 >>> print(value) good MORNING >>> print(value.upper()) ## 全部转换为大写 GOOD MORNING >>> print(value.lower()) ## 全部转换为
阅读全文
摘要:1、使用conda创建环境遇到如下问题: 2、备份原来的配置文件 mv .condarc .condarc.backup 3、创建新的配置文件 vim .condarc ##输入: channels: - https://mirrors.tuna.tsinghua.edu.cn/anaconda/p
阅读全文
摘要:1、查看当前python pythonquit() whereis python which python 2、进入python官网,下载最新安装包 :https://www.python.org/ wget https://www.python.org/ftp/python/3.8.3/Pytho
阅读全文