Python 中如何写if
python
content=str.find('ok') && content=str.find('not ok')
这样表示 在内容中找到 ok 或者 找到 not ok 对吗?
并列条件用 and 而不是&&
或者条件用 or 而不是||
你的意思应该是or 你是都错了
找本教程看看吧,可以google搜索python
content=str.find('ok' or 'not ok')
可以这样写吗?
下面有一句是
if content <> -1:
.............
那我上面的 content=str.find('ok' or 'not ok') 对吗?
只能上CSDN 查不了 下不了
http://search.download.csdn.net/search/python
可以 be more pythonic way
>>> s = 'is it ok for ya?'
>>> if 'ok' in s:
... print 'affirmative'
...
affirmative
>>>
相关问答:
像 C 的 scanf() 那样
比如读入 1 2 3 a b c
每次读入一个
下面这个应该是你想要的吧:
Python code:
>>> k = raw_input()
0 0123 ds dsl sd
>>> k
'0 0123 ds dsl sd'
>>> ......
s='aaa111aaa,bbb222,333ccc,444ddd444,555eee666,fff777ggg'
用正则表达式取出 前后字母相同的数据 结果如下:
111 ddd
谢谢~
Python code:
import re
s='aaa111aaa,bbb222,333ccc,444ddd444,555eee666,ff ......
例如:
ss = "E:\ALL\20100201_NEW\script\lib\core\core"
strs = ss.replace("\\", "/")
print strs
输出:
E:/ALL�0201_NEW/script/lib/core/core
......
Python 怎样启动远程的QTP,然后执行某个路径下的TEST ?
VB可以这样:
Set qtApp = CreateObject("QuickTest.Application", "192.168.0.102")
qtApp.Launch
qtApp.Visible = T ......
菜手请教诸位老鸟:
我希望编辑zip压缩包里的一个文本文件。怎么解决比较合理?
我的想法:先把ZIP解压,再编辑文本,然后再压缩成ZIP并把解压过的文件删除。不过感觉有些繁琐,可不可以直接读ZIP然后修改呢? ......