数据如何发送到服务器?
例如,我检索了MAC地址,因此我想将其发送到服务器(例如:http://211.21.24.43:8080/data?mac=00-0C-F1-56-98-AD)
我在互联网上找到了这个代码片段:
from urllib2 import Request, urlopen
from binascii import b2a_base64
def b64open(url, postdata):
req = Request(url, b2a_base64(postdata), headers={'Content-Transfer-Encoding': 'base64'})
return urlopen(req)
conn = b64open("http://211.21.24.43:8080/data","mac=00-0C-F1-56-98-AD")
但是当我运行它时,出现了以下错误:
File "send2.py", line 8
SyntaxError: Non-ASCII character '\xc3' in file send2.py on line 8, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
有人能帮我发送数据到服务器吗?
谢谢你的帮助!