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
>>>
相关问答:
已知Python 中:
s = unicode("测试", "gb2312")
s = u'\u6d4b\u8bd5'
print s
测试
在Delphi里面如何将\u6d4b\u8bd5这样的还原成Gb2312的汉字呢?
找到个方法
......
我想用python解析网页中的url 在下载之前, 我想先发一个head请求 不需要下载整个网页, 先获得该网站的head信息, 读取一些信息之后 在调用这些库的read方法来读取整个网页 该怎么操作呢 多谢
帮顶了
有人能指教一 ......
return func 与return func()
有什么不同的?
return func返回的是一个函数对象,
return func()返回的是func()函数的返回结果。
楼上正解
一个是返回变量 一个是返回的时候 再调用一下func函数
我觉得是 ......
例如:
ss = "E:\ALL\20100201_NEW\script\lib\core\core"
strs = ss.replace("\\", "/")
print strs
输出:
E:/ALL�0201_NEW/script/lib/core/core
......
菜手请教诸位老鸟:
我希望编辑zip压缩包里的一个文本文件。怎么解决比较合理?
我的想法:先把ZIP解压,再编辑文本,然后再压缩成ZIP并把解压过的文件删除。不过感觉有些繁琐,可不可以直接读ZIP然后修改呢? ......