“print expr"的无效语法错误? [英] Invalid syntax error for "print expr"?

查看:31
本文介绍了“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()

我收到一个错误,指出该行的语法无效:

I'm getting an error stating invalid syntax for the line:

print time.ctime()

请帮帮我.

推荐答案

这是因为(至少在 Python 3.0 之后),print 是一个函数.

This is because (in Python 3.0 onwards at least), print is a function.

使用:

print (time.ctime())

应该没问题.

这篇关于“print expr"的无效语法错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆