“print expr”的语法错误无效?
import os
import sys, urllib2, urllib
import re
import time
from threading import Thread
class testit(Thread):
def _init_ (self):
Thread.__init__(self)
def run(self):
url = 'http://games.espnstar.asia/the-greatest-odi/post_brackets.php'
data = urllib.urlencode([('id',"btn_13_9_13"), ('matchNo',"13")])
req = urllib2.Request(url)
fd = urllib2.urlopen(req, data)
"""while 1:
data = fd.read(1024)
if not len(data):
break
sys.stdout.write(data)"""
fd.close();
url2 = 'http://games.espnstar.asia/the-greatest-odi/post_perc.php'
data2 = urllib.urlencode([('id',"btn_13_9_13"), ('matchNo',"13")])
req2 = urllib2.Request(url2)
fd2 = urllib2.urlopen(req2, data2)
while 1:
data2 = fd2.read(1024)
if not len(data2):
break
sys.stdout.write(data2)
fd2.close()
print time.ctime()
print " ending thread\n"
i=-1
while i<0:
current = testit()
time.sleep(0.001)
current.start()
我收到一条错误,指出该行的语法无效:
print time.ctime()
请帮助我。
import os
import sys, urllib2, urllib
import re
import time
from threading import Thread
class testit(Thread):
def _init_ (self):
Thread.__init__(self)
def run(self):
url = 'http://games.espnstar.asia/the-greatest-odi/post_brackets.php'
data = urllib.urlencode([('id',"btn_13_9_13"), ('matchNo',"13")])
req = urllib2.Request(url)
fd = urllib2.urlopen(req, data)
"""while 1:
data = fd.read(1024)
if not len(data):
break
sys.stdout.write(data)"""
fd.close();
url2 = 'http://games.espnstar.asia/the-greatest-odi/post_perc.php'
data2 = urllib.urlencode([('id',"btn_13_9_13"), ('matchNo',"13")])
req2 = urllib2.Request(url2)
fd2 = urllib2.urlopen(req2, data2)
while 1:
data2 = fd2.read(1024)
if not len(data2):
break
sys.stdout.write(data2)
fd2.close()
print time.ctime()
print " ending thread\n"
i=-1
while i<0:
current = testit()
time.sleep(0.001)
current.start()
I'm getting an error stating invalid syntax for the line:
print time.ctime()
Please help me out.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是因为(至少在 Python 3.0 中),print 是一个函数。
使用:
应该没问题。
This is because (in Python 3.0 onwards at least), print is a function.
Use:
and it should be fine.
来自此页面:
ctime
需要一个参数,但您没有给它一个参数。如果您想获取当前时间,请尝试使用time.time()
。或者,如果您尝试将当前时间(以秒为单位)转换为本地时间的字符串,您应该尝试以下操作:From this page:
ctime
requires an argument and you aren't giving it one. If you're trying to get the current time, trytime.time()
instead. Or, if you're trying to convert the current time in seconds to a string in local time, you should try this: