python Data type conversation
>>> repr(111.5)
'111.5'
>>> repr(10)
''
>>> int("")
11
>>> long("")
22L
>>> float("1.22")
1.22
>>> hex(19)
'0x13'
>>> oct(20)
''
>>> tuple("1,2,3,4,5")
('', ',', '', ',', '', ',', '', ',', '')
>>> tuple("")
('', '', '', '', '')
>>> tuple([1,2,3,4,5])
(1, 2, 3, 4, 5)
>>> tuple({1:2,3:4})
(1, 3)
>>> list((1,2,3,4,5))
[1, 2, 3, 4, 5]
>>> list("")
['', '', '', '', '']
>>> list({1:2,3:4})
[1, 3]
>>>
>>> chr(65)
'A'
>>> ord("A")
65
#list to str
>>> "".join(["a",""])
'a1'
python Data type conversation的更多相关文章
- Python报错:TypeError: data type not understood
K-Means聚类算法 def randCent(dataSet, k): m, n = dataSet.shape # numpy中的shape函数的返回一个矩阵的规模,即是几行几列 centrod ...
- 诡异错误二:TypeError: data type not understood
如何使用Python产生一个数组,数组的长度为1024,数组的元素全为0? 很简单啊, 使用zeros(1024) 即可实现! 如何产生一个2×1024的全0矩阵呢?是否是zeros(2,1024) ...
- Python中type的用法
目录 描述 语法 用法 type和isinstance Type和Object 描述 python的 type 函数有两个用法,当只有一个参数的时候,返回对象的类型.当有三个参数的时候返回一个类对象. ...
- PHP 笔记一(systax/variables/echo/print/Data Type)
PHP stands for "Hypertext Preprocessor" ,it is a server scripting language. What Can PHP D ...
- JAVA 1.2(原生数据类型 Primitive Data Type)
1. Java的数据类型分为2类 >> 原生数据类型(primitive data type) >> 引用数据类型(reference data type) 3. 常量和变量 ...
- salesforce 零基础开发入门学习(四)多表关联下的SOQL以及表字段Data type详解
建立好的数据表在数据库中查看有很多方式,本人目前采用以下两种方式查看数据表. 1.采用schema Builder查看表结构以及多表之间的关联关系,可以登录后点击setup在左侧搜索框输入schema ...
- The conversion of a varchar data type to a datetime data type resulted in an out-of-range value
刚刚有在程序中,传递一个空值至MS SQL Server数据库,这个值的数据类型为DATETIME执行时,它却发生了如标题提示的异常:The conversion of a varchar data ...
- XML Data Type Methods(一)
XML Data Type Methods(一) /*XML Data Type Methods: 1.The query('XQuery') method retrieves(vt.检索,重新得到) ...
- include pointers as a primitive data type
Computer Science An Overview _J. Glenn Brookshear _11th Edition Many modern programming languages in ...
随机推荐
- MySQL临时表
当你创建临时表的时候,你可以使用temporary关键字.如: create temporary table tmp_table(name varchar(10) not null,passwd ch ...
- 在centos7上作用mongodb
安装服务端 yum install mongodb-server 安装客户端 yum install mongodb 版本 mongo --version 是否安装了mongodbwhich mong ...
- 1017作业:配置java环境,学习流程图
- DEV GridControl TableView隔行换色/奇偶行换色
GridControl中的TableView“奇偶行换色”这件事情纠结了我好几天,虽然已经是上个月的事情,好歹记录一下吧,万一有谁要用到呢. GridControl是长这个样子的, <dxg:G ...
- C++ 高级语法学习与总结(代码实例)
C++11增加了许多的特性,auto就是一个很明显的例子. 还有就是typedid()获取数据变量的类型 看下面简短的代码: atuo: 很像java中的加强for循环..... //获取一个数据 ...
- Teach Yourself Programming in Ten Years
Teach Yourself Programming in Ten Years——用十年教会自己编程 作者:Peter Norvig 译者:刘海粟 本文原文为:http://norvig.com/21 ...
- easyui treegrid 分页
$(function () { $('#maintable').treegrid({ width: '98%', height: 550, nowrap: true, striped: true, f ...
- BestCoder Round #41
T1:ZCC loves straight flush(hdu 5228) 题目大意: 给出5张牌,问至少替换多少张牌可以构成同花顺. 题解: 1.直接枚举所有同花顺(枚举花色A-D和最小的数字1-1 ...
- Linux摄像头驱动学习之:(三)从零写虚拟驱动(仿照vivi.c)
本篇仿照vivi.c 写虚拟视频驱动,代码(myvivi.c+fillbuf.c+Makefile)如下: //==========================myvivi.c========== ...
- Visual Studio 编译项目失败,提示找不到文件
博客地址:http://blog.csdn.net/FoxDave 今天碰到了一个蠢问题,虽然咱们正常情况下是遇不到的,但这确实是个应该注意的地方,所以简单记录一下. Visual Studio ...