python_code list_1
>>> def is_not_empty(s):
return s and len(s.strip()) > 0
>>> filter(is_not_empty, ['test', None, '', 'str', ' ', 'END'])
<filter object at 0x1056a3518>
>>> chr(0x1056a3518)
Traceback (most recent call last):
File "<pyshell#113>", line 1, in <module>
chr(0x1056a3518)
OverflowError: signed integer is greater than maximum
>>> hex(9)
'0x9'
>>> hex(226)
'0xe2'
>>> help(hex)
Help on built-in function hex in module builtins:
hex(number, /)
Return the hexadecimal representation of an integer.
>>> hex(12648430)
'0xc0ffee'
>>> input('please input keyword,thank you')
please input keyword,thank you02
'02'
>>> list([1,2,3])
[1, 2, 3]
>>> set([1.1,2,3])
{1.1, 2, 3}
>>> tuple([1,'str',5.0])
(1, 'str', 5.0)
>>> dict([2:1.2,5:3.2])
SyntaxError: invalid syntax
>>> dict([2:'name',3:'stress'])\
SyntaxError: invalid syntax
>>> dict([2 : 'name',3 : 'stress'])
SyntaxError: invalid syntax
>>> dict(a='a',b='b',t='t')
{'b': 'b', 't': 't', 'a': 'a'}
>>> a = set([(1,2)])
>>> dict(a)
{1: 2}
>>> a = [(1,'a'),['a',1]]
>>> dict(a)
{1: 'a', 'a': 1}
>>> a = ('ac',set('de'))
>>> dict(a)
{'e': 'd', 'a': 'c'}
>>> def f(x)
SyntaxError: invalid syntax
>>> def f(x):
return x*x
>>> print map(f,[1,2,3,4,5,6,7,8,8])
SyntaxError: invalid syntax
>>> max([2,4,6,8,9])
9
>>> min([1,0.5,8,6])
0.5
>>> a = iter('abcd')
>>> next(a)
'a'
>>> next(a)
'b'
>>> next(a)
'c'
>>> next(a)
'd'
>>> next(a,'e')
'e'
>>> sum([1,5,8,9])
23
>>> oct(138)
'0o212'
>>> ord('a')
97
>>> pow(2,3)
8
>>> range(1,3)
range(1, 3)
>>> range(1,5,2)
range(1, 5, 2)
>>> range(5)#not include five
range(0, 5)
>>> reversed
<class 'reversed'>
>>> reversed([1,2,3,4,5,6,7])
<list_reverseiterator object at 0x105686f60>
>>> round(1.5778,2)
1.58
>>> str(5648+)
SyntaxError: invalid syntax
>>> str(546)
'546'
>>> str(545.)
'545.0'
>>> type(str)
<class 'type'>
>>> type(132)
<class 'int'>
>>> x = [1,2,3]
>>> y = [4,5,6]
>>> z = [7,8,9]
>>> xyz = zip(x,y,z)
>>> print xyz
SyntaxError: Missing parentheses in call to 'print'
>>> print (xyz)
<zip object at 0x1056a8f08>
>>> import (sys.builtin_module_names)
SyntaxError: invalid syntax
>>> import sys
>>> print(sys.builtin_module_names)
('_ast', '_codecs', '_collections', '_functools', '_imp', '_io', '_locale', '_operator', '_signal', '_sre', '_stat', '_string', '_symtable', '_thread', '_tracemalloc', '_warnings', '_weakref', 'atexit', 'builtins', 'errno', 'faulthandler', 'gc', 'itertools', 'marshal', 'posix', 'pwd', 'sys', 'time', 'xxsubtype', 'zipimport')
>>> help('module')
No Python documentation found for 'module'.
Use help() to get the interactive help utility.
Use help(str) for help on the str class.
>>> help(_ast)
Traceback (most recent call last):
File "<pyshell#169>", line 1, in <module>
help(_ast)
NameError: name '_ast' is not defined
>>> help('_ast')
python_code list_1的更多相关文章
- python_code list_3
>>> seq=['foo','x41','?','***']>>> def func(x): return x.isalnum() >>> li ...
- python_code list_2
>>> import math>>> math.sin(0.5)0.479425538604203>>> >>> import ...
- python 数据类型 --- 集合
1. 注意列表和集合的区别 set 列表表现形式: list_1 = [1,3,4]; 集合表现形式:set_1= set() list_1 = [1,2,3,4,23,4,2] print(lis ...
- Basic Tutorials of Redis(6) - List
Redis's List is different from C#'s List,but similar with C#'s LinkedList.Sometimes I confuse with t ...
- python基础之函数
python 函数 函数是组织好的,可重复使用的,用来实现单一,或相关联功能的代码段. 函数能提高应用的模块性,和代码的重复利用率.你已经知道Python提供了许多内建函数,比如print().但你也 ...
- Python 数据类型及其用法
本文总结一下Python中用到的各种数据类型,以及如何使用可以使得我们的代码变得简洁. 基本结构 我们首先要看的是几乎任何语言都具有的数据类型,包括字符串.整型.浮点型以及布尔类型.这些基本数据类型组 ...
- Python-09-线程、进程、协程、异步IO
0. 什么是线程(thread)? 线程,有时被称为轻量级进程(Lightweight Process,LWP),是程序执行流的最小单元.一个标准的线程由线程ID,当前指令指针(PC),寄存器集合和堆 ...
- Python-03-基础
一.集合 集合(set)是一个无序的.不重复的元素组合,它的主要作用如下: 去重:把一个列表变成集合,就会自动去重. 关系测试:测试两组数据之前的交集.差集.并集等关系. 常用操作 # 创建数值集合 ...
- Python学习Day2笔记(集合和文件操作)
1.集合的使用 列表是有序的可包含重复内容的 集合是无序的不可包含重复内容的 1) 集合关系测试 #列表去重list_1=[1,4,5,6,7,8,9,7,5,4,23,2] #有重复数据 list_ ...
随机推荐
- 小强的HTML5移动开发之路(3)——HTML5与HTML4比较
来自:http://blog.csdn.net/dawanganban/article/details/17652873 在前面介绍了HTML5的新特性,新标签的使用,智能表单设计,引入多媒体对象,C ...
- (NO.00001)iOS游戏SpeedBoy Lite成形记(二)
打开SpriteBuilder生成的Xcode项目文件,首先在MainScene添加play回调函数: -(void)play{ CCScene *gameScene = [CCBReader loa ...
- 轻量级网络库libevent概况
Libevent is a library for writing fast portable nonblocking IO. libevent是一个为编写快速可移植的非阻塞IO程序而设计的. lib ...
- Android服务器——TomCat服务器的搭建
Android服务器--TomCat服务器的搭建 作为一个开发人员,当然是需要自己调试一些程序的,这个时候本地的服务器就十分方便了,一般都会使用TomCat或者IIS服务器,IIS就比较简单了,其实t ...
- Auto Create Editable Copy Font(Unity3D开发之二十二)
猴子原创,欢迎转载.转载请注明: 转载自Cocos2Der-CSDN,谢谢! 原文地址: http://blog.csdn.net/cocos2der/article/details/48318879 ...
- CImage 对话框初始化时候显示透明 PNG
使用CImage的时候,发现显示出来的并不是透明背景的图片,而是白色背景的图片. 后发现原因如下: PNG图片的透明背景总是一片白色,后来才发现这其实是微软GDI+的设计问题,PNG图片是ARGB,使 ...
- linux设备驱动程序--类class的实现
#include <linux/module.h> #include <linux/fs.h> #include <linux/sched.h> #include ...
- obj-c编程10:Foundation库中类的使用(5)[时间对象]
隔了好久才有了这新的一篇,还是无奈的时间啊!so这次我们就着重谈谈它喽. F库中有很多时间相关的类,比如NSDate,NSTimeInterval,NSTimeZone,NSDateComponent ...
- asp.net 调试与iis部署的问题
第一个问题:编译器错误信息: CS0016: 未能写入输出文件"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET ...
- python之多继承与__mro__的使用
1 class Base(object): def text(self): print('------text-----') class A(Base): def text(self): print( ...