“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()
请帮帮我。
2 个回答
-2
来自 这个页面:
ctime(...)
ctime(秒数) -> 字符串
把从“纪元”开始的秒数转换成当地时间的字符串。
这和 asctime(localtime(秒数)) 是一样的。
ctime
需要一个参数,但你没有给它。 如果你想获取当前时间,可以试试 time.time()
。或者,如果你想把当前的秒数转换成当地时间的字符串,可以试试这个:
time.ctime(time.time())
4
这是因为(至少在Python 3.0及之后的版本中),print是一个函数。
你可以使用:
print (time.ctime())
这样就没问题了。