【Python】函数形参中的【*args】和【**kwargs】

xixuefeng Python 2018-02-27 886 次浏览 ,
一:*args 将实参按照位置与形参对应传入,多出来的值都给args,并且以元组的方式展现出来 1:两个参数,一个参数p加上一个参数*args [crayon-6623dfcddd197971126785/] 2:三个参数,p,t,*args,有了上面的测试,这个就很好理...

【Python】str.format

xixuefeng Python 2018-02-26 973 次浏览
format给人的感觉比%更有优势。 1:format的内容替换大括号 [crayon-6623dfcddf20a164008577/] 2:多个参数的例子 [crayon-6623dfcddf210017904849/] 3:大括号的编号可以出现多次,只要能匹配上参数即可 [crayon-6623dfcddf2...

【Python】print 常用格式化输出

xixuefeng Python 2018-02-25 1,646 次浏览
一:常用字符串格式化符号 1:%c 格式化单个字符或其ASCII码 [crayon-6623dfcde0982463650255/] 2:%s 格式化字符串 [crayon-6623dfcde0987387558287/] 3:%d 格式化整数 [crayon-6623dfcde098b968228715/] 4:%f 格式化浮点数...

【Python】字符串的 “*” “+”

xixuefeng Python 2018-02-20 807 次浏览
1:在数学运算里,“*”,就是两个数字相乘,例如: [crayon-6623dfcde215d316555253/] 2:字符串中也可以使用“*”,相当于复制字符串,例如: [crayon-6623dfcde2162036431028/] 3:字符串相加,这没什么好说的 [crayon-6623dfcde...

【Python】print()

xixuefeng Python 2018-02-19 985 次浏览
3.6.4官方文档如下: print(objects, sep=' ', end='\n', file=sys.stdout, flush=False) print所有的参数均为可选项,我们最常用的方式为(以hello world为例,sep,end,file,flush均采用默认值) [crayon-6623dfcde3805167569...

【Python】异常处理 try…except

xixuefeng Python 2018-02-09 823 次浏览
无论是为了健壮性考虑还是获取错误信息,异常处理是必不可少的,那么本测试简单测试一下。 1:捕获所有异常 [crayon-6623dfcde4ed6159546488/] 2:利用sys模块 [crayon-6623dfcde4edb234634715/] 当然,sys.exc_info()是列表,...

【Python】py编译pyc

xixuefeng Python 2018-01-26 961 次浏览
有多种方法,作者常用办法: [crayon-6623dfcde6526728171982/] 例: [crayon-6623dfcde652b211059879/]  

【Python】ImportError: bad magic number in ‘pyc.OpenCF’: b’3\r\r\n’

xixuefeng Python 2017-09-22 3,626 次浏览
不同版本的python环境下执行python程序,报如下错误 [crayon-6623dfcde7b05237375261/] 原因是编译后的pyc与python环境版本不一致造成的。 重新用当前环境编译python程序 [crayon-6623dfcde7b0b036476409/] 将编译后的文件放到...

【Python 3.6.2】安装 pymssql 包 _mssql.c:266:22: fatal error: sqlfront.h: No such file or directory

xixuefeng Linux, Other, Python 2017-08-21 4,274 次浏览
Python3 在安装 pymssql包时,报如下错误 [crayon-6623dfcde9126846685339/] 解决此问题方法 [crayon-6623dfcde912d919509675/]  

【CentOS 7】安装pip

xixuefeng Linux, Python 2017-08-14 1,883 次浏览
1:利用 CentOS 默认的yum源找不到 pip [crayon-6623dfcdea79d968295358/] 2:通过安装EPEL扩展仓库后再安装pip EPEL(Extra Packages for Enterprise Linux 简称), 是为企业级 linux 提供的一组高质量的额外软件包, 包括但不限于...
回顶部