ChinaUnix.net
相关文章推荐:

python 多行字符串

var.py: s = This is a multi-line string. This is the second line. print s run "python var.py" 书上说结果应该是: This is a multi-line string. This is the second line. 但输出为: File "var.py", line 1 s = This is a multi-line string. ^ SyntaxError: invalid syntax 甚至print Hello World都说: File "helloworld.py", line 1 print Hello World ...

by 共舞秋雨 - Python - 2009-09-23 12:44:12 阅读(11745) 回复(7)

相关讨论

比如字符串 S1= 123 456 789 012 我想匹配 以456开始到789结束在内的所�行� 怎么处理啊 请指教?~~~

by soulsnake - Python - 2008-11-19 10:59:51 阅读(6082) 回复(3)

看到门多帖子说多行注释用"""......"""或者'''.....'''可是我在python shell 中怎么不行啊!!!

by 0820LL - Python - 2012-12-22 10:34:29 阅读(16904) 回复(8)

我用三个单引号 ''' 或者3个 """来注释几行时,解释器提示说: """ ^ IndentationError: expected an indented block,比较郁闷,书上是这么说注释的。。。。

by lemonniu - Python - 2008-11-01 12:02:02 阅读(3279) 回复(2)

初看之下,python 里缺少块注释(block comment)。 解决方法 把 code block 放在if 0: ... 的缩进块里 用”“”或者'''的 triple quotes 把要注释的代码包起来。不过这种办法必须要注意 triple quotes 的缩进,必须服从上下文。另外,被注释的代码不能含有 triple quote(s)。 像样的编辑器都应该有块注释的功能。Emacs: C-c # 就是块注释,C-u C-c # 就是取消块注释 每一行都用“#”自有它的好处,而块注释标记则有其让人...

by linxh - Python文档中心 - 2006-10-18 06:45:51 阅读(1590) 回复(0)

各位大哥好,小弟写了个html页面POST一些内容到python脚本 如何在脚本里将这些内容直接转换成列表?

by sqy614 - Python - 2012-07-04 16:19:27 阅读(1415) 回复(0)

[code]typedef union { ... } AA; typedef union { ... } BB; typedef union { ... } CC; [/code]我想中上面的的文本中提取出 union CC的定义。 我试了下以下正则式:[code]re.compile(r'typedef union \{(.*?)\} CC', re.S|re.M)[/code]得到的结果是:[code]>>> pat.search(msg).groups()[0] ' \n...\n} AA;\n\ntypedef union { \n...\n} BB;\n\ntypedef union { \n...\n'[/code]好像没有去...

by Suchangyu - Python - 2011-10-03 11:00:18 阅读(2486) 回复(1)

读取下面的文件,重新组合字符,合并成输出格式为由Line开头的3行。 需要读取的数据文件如下 Line1 Q E Line2 P E Line3 P V 想要达到的输出方式如下 Line1 QE Line2 PE Line3 PV 我写了一个程序只能按照原来的格式进行输出,请帮我看看如何进行那三行的重新排列。多谢!! #!/usr/bin/python import sys filename=sys.argv[1] data=open(filename) a=0 lines = data.readlines() for linestr in lines: lines...

by s081009 - Python文档中心 - 2014-06-22 20:14:27 阅读(16476) 回复(3)

str = dom.getElementsByTagName('Message')[0].getElementsByTagName('Body')[0].getElementsByTagName('response')[0].getElementsByTagName('parameter')[0].getElementsByTagName('file')[0].firstChild.data 这行代码能否像别的语言一样换行?

by lvxinzhi - Python - 2013-02-18 12:31:33 阅读(24784) 回复(5)

如题,我只要替换掉下面的版权信息,为“xxx”该如何编写python脚本呢?请指教,不甚感激,我可以另外开贴追加200分 /* * Copyright 2002 Sun Microsystems, Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * ...

by 吴秦 - Python - 2010-08-29 17:29:48 阅读(8041) 回复(14)