-1
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()

请帮帮我。

4

2 回答 2

4

这是因为(至少在 Python 3.0 及更高版本中), print 是一个函数。

采用:

print (time.ctime())

应该没问题。

于 2009-09-16T19:02:59.563 回答
-2

这个页面

ctime(...)

ctime(秒) -> 字符串

将自 Epoch 以来的以秒为单位的时间转换为本地时间的字符串。

这相当于 asctime(localtime(seconds))。

ctime需要一个论点,而你没有给它一个论点。如果您想获取当前时间,请尝试time.time()。或者,如果您尝试将当前时间(以秒为单位)转换为本地时间的字符串,您应该尝试以下操作:

time.ctime(time.time())
于 2009-09-16T18:59:35.577 回答