ChinaUnix.net
相关文章推荐:

str r14r13#4

python的类里面可以定义__str__()函数。如果定义了这个函数,当str()这个类的对像的时候就是调用的类的__str__()函数。__str__()函数必须要返回一个字符串。 同样的__unicode__也是这个道理。此外还有很多其他的函数也是这样。但不是所有的函数都可以,例如要是自定一个__Atest__()就不行。代码如下: #coding:utf-8 class AA(): def __Atest__(self): print "hello" def __unicode__(self): ...

by pgt112you - Python文档中心 - 2009-10-11 20:36:36 阅读(2013) 回复(0)

相关讨论

printf("%s", str) vs. printf(str) Created: Fang lungang 03-08-2007Modified: Fang lungang 03-08-2007 21:35> 从 The C Programming Language 2nd 看到的 printf 一个需要注意的细节:即使被打印的本身就只有一个字符串,最好也别直接打印,而要用格式符 %s。其它格式输出的函数应该也类似。 #include int main() { char* str= "a string with % may not workn"; printf ("%s", str); printf (str);...

by 剑心通明 - php文档中心 - 2008-05-17 08:41:40 阅读(593) 回复(0)

empty($str)与$str==''哪个效率高???

by 115300111 - PHP - 2007-08-18 10:06:50 阅读(3162) 回复(11)

小弟c语言不精,基础不好 感问char *str跟 char str[]的区别 [code] int main() { char *str="hello"; char str2[6]="hello"; *str="other"; str2[6]="other"; if(!strcmp(str,"hello"))printf("\n*str"); if(!strcmp(str2,"hello"))printf("\nstr[]"); return 0; } [/code] 上面的两种情况会有不同的结果 [ 本帖最后由 ydlhero 于 2006-8-10 16:37 编辑 ]

by ydlhero - C/C++ - 2006-08-10 20:12:42 阅读(1542) 回复(7)

今有类似字符串如下: string =

string = 'abc'>xxxxx

str函数里有没有某个函数或者某些函数凑合起来,然后把<>和它里面的内容去掉,之保留xxxxx内容。? 查了半天,没个头绪。

by lemonniu - Python - 2008-10-16 16:39:26 阅读(2371) 回复(5)

[color="#0000bb"] 字符串取代。 [color="#ff8000"]语法: string str_replace(string needle, string str, string haystack); [color="#ff8000"]返回值: 字符串 [color="#ff8000"]函数种类: 资料处理 [color="#ff8000"]内容说明 本函数将字符串 str 代入 haystack 字符串中,将所有的 needle 置换成 str。mlevine@adtraq.com (11-Apr-1999) 指出在 PHP 3.0.7 版,本函数有些 bug,而...

by rainbutterfly - php文档中心 - 2007-07-26 17:46:22 阅读(364) 回复(0)

查资料得 (?=...) 如果前瞻查找断言成功,返回真 但是我还是想不明白 0不也匹配\d的么? 那到底什么情况下断言会查找成功呢? [ 本帖最后由 justlooks 于 2009-2-23 13:14 编辑 ]

by justlooks - Perl - 2009-02-26 09:11:22 阅读(1516) 回复(8)

function ChkUtil() { //校验是否为空(先删除二边空格再验证) ChkUtil.isNull = function (str) { if (null == str ||""== str.trim()) { return true; } else { return false; } }; } 这个该怎么调用啊? 其中ChkUtil.isNull 和 this.isNull这样写一样吗? JScript code script type="text/javascript"> function ChkUtil() { d="123" //校?是否?空(先?除二?空格再??) ChkUtil.isNull = function (str) { if (null == ...

by militala - php文档中心 - 2009-01-13 12:03:32 阅读(1060) 回复(0)

function ChkUtil() { //校验是否为空(先删除二边空格再验证) ChkUtil.isNull = function (str) { if (null == str ||""== str.trim()) { return true; } else { return false; } }; } 这个该怎么调用啊? 其中ChkUtil.isNull 和 this.isNull这样写一样吗? JScript code script type="text/javascript"> function ChkUtil() { d="123" //校?是否?空(先?除二?空格再??) ChkUtil.isNull = function (str) { if (null == ...

by militala - php文档中心 - 2009-01-13 12:03:24 阅读(965) 回复(0)

#include #include <string> using namespace std; main() { string str1 = "hello world"; printf ("\tstr1's address: %x\n", str1.c_str() ); printf ("\tstr1's address: %x\n", &str1); } 程序的输出结果不一样。为什么?

by kewenliang - C/C++ - 2008-06-19 18:42:39 阅读(3112) 回复(11)

char str[10]; memset(str,0,sizeof(str))和memset(&str,0,sizeof(str))的区别在那里? 请高手指点阿!!! [ 本帖最后由 wangjm213 于 2006-2-28 10:36 编辑 ]

by wangjm213 - C/C++ - 2006-03-13 09:54:30 阅读(6729) 回复(33)