質問

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

手伝ってください。

役に立ちましたか?

解決

(少なくともPython 3.0以降では)printは関数であるためです。

使用:

print (time.ctime())

それで問題ないはずです。

他のヒント

このページから:

  

ctime(...)

     

ctime(seconds)-&gt;文字列

     

エポック以降の時間を秒単位でローカル時間の文字列に変換します。

     

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

ctime には引数が必要ですが、引数を指定していません。現在の時刻を取得しようとしている場合は、代わりに time.time()を試してください。または、現在の時間を秒単位でローカル時間の文字列に変換しようとしている場合は、これを試してください:

time.ctime(time.time())
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top