-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(秒)->文字列

エポックからの秒単位の時間を現地時間の文字列に変換します。

これは、asctime(localtime(seconds))と同等です。

ctime引数が必要であり、あなたはそれに引数を与えていません。現在の時刻を取得しようとしている場合は、time.time()代わりに試してください。または、秒単位の現在の時刻を現地時間の文字列に変換しようとしている場合は、次のことを試してください。

time.ctime(time.time())
于 2009-09-16T18:59:35.577 に答える