ChinaUnix.net
相关文章推荐:

python随机字符

随机整数: >>> import random >>> random.randint(0,99) 21 随机选取0到100间的偶数: >>> import random >>> random.randrange(0, 101, 2) 42 随机浮点数: >>> import random >>> random.random() 0.85415370477785668 >>> random.uniform(1, 10) 5.4221167969800881 随机字符: >>> import random >>> random.choice('abcdefg&#%^*f') 'd' 多个字符中选取特定数量的字符: >>> import random random.sample('...

by mystérieux - Python文档中心 - 2007-09-03 19:29:30 阅读(2883) 回复(0)

相关讨论

[color="#0000f0"] 随机整数: >>> import random >>> random.randint(0,99) 21 [color="#000080"]随机选取0到100间的偶数: >>> import random >>> random.randrange(0, 101, 2) 42 [color="#0000f0"]随机浮点数: >>> import random >>> random.random() 0.85415370477785668 >>> random.uniform(1, 10) 5.4221167969800881 [color="#0000f0"]随机字符: >>> import random >>> random.choice('abcdefg&#%^*f') 'd'...

by bj2008_0201 - Python文档中心 - 2008-09-11 10:27:44 阅读(1802) 回复(0)

随机整数: >>> import random >>> random.randint(0,99) 21 随机选取0到100间的偶数: >>> import random >>> random.randrange(0, 101, 2) 42 随机浮点数: >>> import random >>> random.random() 0.85415370477785668 >>> random.uniform(1, 10) 5.4221167969800881 随机字符: >>> import random >>> random.choice('abcdefg&#%^*f') 'd' 多个字符中选取特定数量的字符: >>> import random random.sample('abcdefghij',3) ...

by alexnetwork - Python文档中心 - 2009-03-11 21:56:01 阅读(1047) 回复(0)

#python字符串操作 '''1.复制字符串''' #strcpy(sStr1,sStr2) sStr1 = 'strcpy' sStr2 = sStr1 sStr1 = 'strcpy2' print sStr2 '''2.连接字符串''' #strcat(sStr1,sStr2) sStr1 = 'strcat' sStr2 = 'append' sStr1 += sStr2 print sStr1 '''3.查找字符''' #strchr(sStr1,sStr2) sStr1 = 'strchr' sStr2 = 'r' nPos = sStr1.index(sStr2) print nPos '''4.比较字符串''' #strcmp(sStr1,sStr2) sStr1 = 'strchr' sStr2 = 'strch' pr...

by yangguosdxl - Python文档中心 - 2009-04-17 14:19:01 阅读(1916) 回复(0)

如果要处理python字符python又没有字符类型,只有字符串。 比如c可以'a'+1变成'b’ python中可以怎末做? 多谢各位。

by houwukong - Python - 2008-11-13 16:22:02 阅读(1531) 回复(2)

#python字符串操作 '''1.复制字符串''' #strcpy(sStr1,sStr2) sStr1 = 'strcpy' sStr2 = sStr1 sStr1 = 'strcpy2' print sStr2 '''2.连接字符串''' #strcat(sStr1,sStr2) sStr1 = 'strcat' sStr2 = 'append' sStr1 += sStr2 print sStr1 '''3.查找字符''' #strchr(sStr1,sStr2) sStr1 = 'strchr' sStr2 = 'r' nPos = sStr1.index(sStr2) print nPos '''4.比较字符串''' #strcmp(sStr1,sStr2) sStr1 = 'strchr' sStr2 = 'strch' pr...

by jcodeer - Python文档中心 - 2007-09-15 02:34:31 阅读(1028) 回复(0)

1 字符串概述 字符串(string)是python内置数据类型的一种,它是一个有序的字符的集合,用于存储和表示基本的文本信息。从功能的角度来看,字符串可以被用于实现任何可以作为文本编码的数据:字母、数字和其他特殊符号的集合,载入读入内存中的文本文件的内容等。 字符串是最常见的数据类型的一种,在任何编程语言都不可或缺的,而且都占有非常重要的地位。为了让大家能从感性上认识到字符串数据的作用,不妨来看看这个简单的例子...

by pascal4123 - Python文档中心 - 2007-07-31 11:00:25 阅读(1224) 回复(0)

比如要生成0-1000之间的一个随机数?应该怎么办 多谢!

by godmatrix - Python - 2008-04-24 14:49:44 阅读(30118) 回复(5)

python list 可以象数组那样随机访问。但访问一个数组元素的消耗是 O(1) 的,访问 python list 的一个元素也是 O(1) 的吗?

by retuor - Python - 2008-01-16 10:17:34 阅读(3445) 回复(4)

python语言中有没有随机函数????

by ragkk - Python - 2005-12-09 23:52:57 阅读(4528) 回复(2)

本文最初发表于赖勇浩(恋花蝶)的博客( http://blog.csdn.net/lanphaday ),如蒙转载,敬请保留全文完整,切勿去除本声明和作者信息。 在编程中,几乎90% 以上的代码都是关于整数或字符串操作,所以与整数一样,python字符串实现也使用了许多拿优化技术,使得字符串的性能达到极致。与 C++ 标准库(STL)中的 std::string 不同,python 字符串集合了许多字符串相关的算法,以方法成员的方式提供接口,使用起来非常方便...

by hkebao - Python文档中心 - 2009-08-15 21:03:25 阅读(1601) 回复(0)