1、*.py文件生成*.pyc、*.pyo文件
python -m py_compile hello.py
python -o -m py_compile hello.py
2、字符串的操作方法(单引号和双引号都可以表示字符串)
str.title()首字母大写的形式格式化输出字符串str.upper()全部大写形式格式化str.lower()全部小写形式格式化str.rstrip()删除结尾的空格,原字符串不变str.lstrip()删除开头的空格,原字符串不变str.strip()删除两头的空格,原字符串不变
3、相关方法
str(num)将num作为字符串来展示
4、list的方法
list.append(new)末尾处添加新值list.insert(index, new)索引index处插入新值del list[index]删除索引index的值str = list.pop()删除末尾的值,该值可以用于其他地方,删除其他位置的,指定index即可list.remove(new)删除指定的值len(list)获取list的长度
5、排序的方法
list.sort()永久性的排序,对原list改变了,可传入参数reverse=True来反转list.sorted()不影响原list的顺序,可传入参数reverse=True来反转list.reverse()永久性反转list
4、我的理解
- python中的list类似于js中的数组,值可以是多种类型
- 2.
1048

被折叠的 条评论
为什么被折叠?



