python 将任意基本类型转化为String型
来源:互联网 发布:linux 僵尸进程 编辑:程序博客网 时间:2024/05/02 02:27
#! /usr/bin/python# -*-coding:utf-8 -*-'''Created on 2014-3-17@author: Java'''def typeCastToString(castParameter): ''' 将任意基本类型的对象转换为字符串 :param castParameter:需要转换的参数 ''' newType=[] if type(castParameter)==int: #整型转字符串 newType = str(castParameter) elif type(castParameter)==list: castParameter_new=[] for i in castParameter: if type(i)==str: newType =','.join(castParameter) elif type(i)==int: i = str(i) castParameter_new.append(i) newType =','.join(castParameter_new) elif type(i)==tuple: i = ','.join(i) castParameter_new.append(i) newType =','.join(castParameter_new) elif type(i)==dict: i = str(i) castParameter_new.append(i) newType =','.join(castParameter_new) # return type(newType) return newType # print typeCast(['1','2','3'])print typeCastToString([{'name':'xiaoming'},{'age':12}])
0 0
- python 将任意基本类型转化为String型
- 将String类型转化为Date类型
- C# 将String类型转化成任意类型
- ParcelableGenerator将任意对象转化为Parcelable类型
- [C#] 如何将String类型转换成任意基本类型
- [C#] 如何将String类型转换成任意基本类型
- 使用python将任意字符串转化为列表
- 将数据库Clob数据转化为String类型
- 将数据库Clob数据转化为String类型
- 如何将 rapidjson::Value 转化为string类型
- sprmvc将前台String转化为后台的Date类型
- sql函数将string类型转化为秒
- go语言如何将时间转化为字符串String类型
- c/c++ 下面 将string类型变量转化为int型
- DecimalFormat 快速将小数转化为保留任意小数位数的String
- 将String转化为Calendar
- string 转化为 char *类型
- CString类型转化为string
- KeySet() 和 EntrySet()
- treeview控件能用的从sql数据源到HierarchicalDataSourceControl数据源转换器
- Codeforces Round #236 (Div. 2) E. Strictly Positive Matrix
- LInux下可以使用命令自动与网络的NTP服务器同步时间 CSDN验证码验证失败问题解决
- linux的<pthread.h>
- python 将任意基本类型转化为String型
- [NLP]Introduction
- UML---statechart diagram
- 关于在做绕开SafeSEH的一个实验时(章节:11.6)一个神奇的事情
- python判断字符串
- Fatal signal 11 (SIGSEGV) at 0x00000048 (code=1)
- proc/sys/net/ipv4/下各项的意义
- 黑马程序员_基础加强_类加载器
- 黑马程序员----多线程3