Python
qq_39389646
这个作者很懒,什么都没留下…
展开
-
Python编译中文乱码
Python编译器编译.py文件出现中文乱码编译乱码提示:SyntaxError: Non-UTF-8 code starting with '\xb2' in file test.py on line 1, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details在文件最开头添加:#...原创 2019-07-02 16:27:12 · 856 阅读 · 0 评论 -
Python变量赋值
python变量赋值问题:>>> a = [1,2,3,4]>>> b = a>>> c = []>>> c = a>>> d = a[:]>>> a,b,c,d([1,2,3,4],[1,2,3,4],[1,2,3,4],[1,2,3,4])>>> b[0...原创 2019-07-05 10:04:03 · 144 阅读 · 0 评论 -
Python元组的命名
元组的命名因为元组的局限性,不能直接对元组及元组内部元素进行命名,我们需要借助collections.namedtuple这个函数来对定义一个带字段名的元组collections.namedtuple的定义格式如下:collections.namedtuple('typename','field_names',verbose=false,rename=false)//函数字段名的含义:/...原创 2019-07-22 10:19:35 · 320 阅读 · 0 评论 -
Python中元组的函数
定义一个带字段名的元组from collections import namedtupleUser = namedtuple('User',['name','sex','age'])user = User('lisi','male',12)print(user) //User(name='lisi',sex='male',age=12)_fields:元组的属性print(user...原创 2019-07-22 13:49:44 · 470 阅读 · 0 评论