自学操作日志-python

Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (Intel)] on win32
Type “copyright”, “credits” or “license()” for more information.
>>> import pymsql
Traceback (most recent call last):
File “<pyshell#0>”, line 1, in <module>
import pymsql
ImportError: No module named ‘pymsql’
>>> import pymsql
Traceback (most recent call last):
File “<pyshell#1>”, line 1, in <module>
import pymsql
ImportError: No module named ‘pymsql’
>>> import pymsql
Traceback (most recent call last):
File “<pyshell#2>”, line 1, in <module>
import pymsql
ImportError: No module named ‘pymsql’
>>> import pymysql
>>> try:
conn = pymysql.connect(host=’localhost’,user=’root’,passwd=’root’,db=’zlinfo’,port=3306,charset=’utf8′))

SyntaxError: invalid syntax
>>> try:


conn = pymysql.connect(host=’localhost’,user=’root’,passwd=’root’,db=’zlinfo’,port=3306,charset=’utf8′)

SyntaxError: unexpected indent
>>> try:
conn = pymysql.connect(host=’localhost’,user=’root’,passwd=’root’,db=’zlinfo’,port=3306,charset=’utf8′)
cur = conn.cursor
cur.execute(‘select * from zlinfo where id <5′)
data = cur.fetchall()
for d in data:
print(“ID:”+str(d[0])+’申请号:’+str(d[1]))
cur.close()
conn.close()
except Exception :print(“有错误”)

有错误
>>> try:
conn = pymysql.connect(host=’localhost’,user=’root’,passwd=’root’,db=’zlinfo’,port=3306,charset=’utf8′)
cur = conn.cursor
cur.execute(‘select * from zlinfo where id <5’)
data = cur.fetchall()
for d in data:
print(“ID:”+str(d[0])+’申请号:’+str(d[1]))
cur.close()
conn.close()
except Exception as e:
print (e)

(1049, “Unknown database ‘zlinfo'”)
>>> try:
conn = pymysql.connect(host=’localhost’,user=’root’,passwd=’root’,db=’zlcms’,port=3306,charset=’utf8′)
cur = conn.cursor
cur.execute(‘select * from zlinfo where id <5’)
data = cur.fetchall()
for d in data:
print(“ID:”+str(d[0])+’申请号:’+str(d[1]))
cur.close()
conn.close()
except Exception as e:
print (e)
‘function’ object has no attribute ‘execute’
>>> try:
conn = pymysql.connect(host=’localhost’,user=’root’,passwd=’root’,db=’zlcms’,port=3306,charset=’utf8′)
cur = conn.cursor()
cur.execute(‘select * from zlinfo where id<10’)
data = cur.fetchall()
for d in data:
print(“ID:”+str(d[0])+’申请号:’+str(d[1]))
cur.close()
conn.close()
except Exception as e:
print (e)
9
ID:1申请号:201010210020
ID:2申请号:201030239032
ID:3申请号:201030239031
ID:4申请号:201020509939
ID:5申请号:201020528643
ID:6申请号:201030514973
ID:7申请号:201020531350
ID:8申请号:201020571025
ID:9申请号:201110220892
>>> file_handler = open(‘http://so.xxxx.com/api.php?key=1451010286&ID=36308a5755eb111781ef72ae1feec14c&code=201510636248&type=2&state=1’)
Traceback (most recent call last):
File “<pyshell#26>”, line 1, in <module>
file_handler = open(‘http://so.xxxx.com/api.php?key=1451010286&ID=36308a5755eb111781ef72ae1feec14c&code=201510636248&type=2&state=1’)
OSError: [Errno 22] Invalid argument: ‘http://so.xxxx.com/api.php?key=1451010286&ID=36308a5755eb111781ef72ae1feec14c&code=201510636248&type=2&state=1’
>>> import urllib2
Traceback (most recent call last):
File “<pyshell#27>”, line 1, in <module>
import urllib2
ImportError: No module named ‘urllib2’
>>> import urllib2
Traceback (most recent call last):
File “<pyshell#28>”, line 1, in <module>
import urllib2
ImportError: No module named ‘urllib2’
>>> import urlib2
Traceback (most recent call last):
File “<pyshell#29>”, line 1, in <module>
import urlib2
ImportError: No module named ‘urlib2’
>>> import urllib
>>> urllib.urlopen(‘http://so.xxxx.com/’)
Traceback (most recent call last):
File “<pyshell#31>”, line 1, in <module>
urllib.urlopen(‘http://so.xxxx.com/’)
AttributeError: ‘module’ object has no attribute ‘urlopen’
>>> urllib.request.urlopen(‘http://so.xxxx.com/’)
Traceback (most recent call last):
File “<pyshell#32>”, line 1, in <module>
urllib.request.urlopen(‘http://so.xxxx.com/’)
AttributeError: ‘module’ object has no attribute ‘request’
>>> urllib.request.urlopen(‘http://so.xxxx.com’)
Traceback (most recent call last):
File “<pyshell#33>”, line 1, in <module>
urllib.request.urlopen(‘http://so.xxxx.com’)
AttributeError: ‘module’ object has no attribute ‘request’
>>> urllib.parse
<module ‘urllib.parse’ from ‘D:\\python3.4\\lib\\urllib\\parse.py’>
>>> form urllib.
SyntaxError: invalid syntax
>>> form urllib.parse import request
SyntaxError: invalid syntax
>>> import urllib.request
>>> from urllib.request import request
Traceback (most recent call last):
File “<pyshell#38>”, line 1, in <module>
from urllib.request import request
ImportError: cannot import name ‘request’
>>> urllib.request.urlopen
<function urlopen at 0x0194D198>
>>> url=’http://so.xxxx.com’
>>> urllib.request.urlopen(url)
<http.client.HTTPResponse object at 0x017E7950>
>>> urllib.request.urlopen(‘http://so.xxxx.com’)
<http.client.HTTPResponse object at 0x017E7970>
>>> urllib.request
<module ‘urllib.request’ from ‘D:\\python3.4\\lib\\urllib\\request.py’>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> urllib.request.urlopen(‘http://so.xxxx.com/api.php?key=1451010286&ID=36308a5755eb111781ef72ae1feec14c&code=201510636248&type=2&state=1’)
<http.client.HTTPResponse object at 0x017E7950>
>>> data = urllib.request.urlopen(‘http://so.xxxx.com/api.php?key=1451010286&ID=36308a5755eb111781ef72ae1feec14c&code=201510636248&type=2&state=1’)
>>> data.length
27
>>> data
<http.client.HTTPResponse object at 0x017921F0>
>>> import httplib

httpclient=None
print ‘bb’
try:
httpclient=httplib.HTTPConnection(‘www.xxx.org’,80)
httpclient.request(‘GET’,’/CloudBean/capture.php?name=liu&pass=wew’)
res=httpclient.getresponse()
print res.status
print res.reason
print res.read()
except Exception,e:
print “heelowr”

SyntaxError: multiple statements found while compiling a single statement
>>> import httplib
Traceback (most recent call last):
File “<pyshell#57>”, line 1, in <module>
import httplib
ImportError: No module named ‘httplib’
>>> import http
>>> import http.c
Traceback (most recent call last):
File “<pyshell#59>”, line 1, in <module>
import http.c
ImportError: No module named ‘http.c’
>>> import http.client
>>> http.client.HTTPResponse
<class ‘http.client.HTTPResponse’>
>>> http.client.HTTPResponse(‘http://so.xxxx.com’)
Traceback (most recent call last):
File “<pyshell#62>”, line 1, in <module>
http.client.HTTPResponse(‘http://so.xxxx.com’)
File “D:\python3.4\lib\http\client.py”, line 290, in __init__
self.fp = sock.makefile(“rb”)
AttributeError: ‘str’ object has no attribute ‘makefile’
>>> http.client.HTTPResponse(‘http://so.xxxx.com’,’80’)
Traceback (most recent call last):
File “<pyshell#63>”, line 1, in <module>
http.client.HTTPResponse(‘http://so.xxxx.com’,’80’)
File “D:\python3.4\lib\http\client.py”, line 290, in __init__
self.fp = sock.makefile(“rb”)
AttributeError: ‘str’ object has no attribute ‘makefile’
>>> http.client.HTTPResponse(‘http://so.xxxx.com’,80)
Traceback (most recent call last):
File “<pyshell#64>”, line 1, in <module>
http.client.HTTPResponse(‘http://so.xxxx.com’,80)
File “D:\python3.4\lib\http\client.py”, line 290, in __init__
self.fp = sock.makefile(“rb”)
AttributeError: ‘str’ object has no attribute ‘makefile’
>>> http.client.HTTPResponse(‘so.xxxx.com’,80)
Traceback (most recent call last):
File “<pyshell#65>”, line 1, in <module>
http.client.HTTPResponse(‘so.xxxx.com’,80)
File “D:\python3.4\lib\http\client.py”, line 290, in __init__
self.fp = sock.makefile(“rb”)
AttributeError: ‘str’ object has no attribute ‘makefile’
>>> h1 = http.client.HTTPConnection(‘www.python.org’)
>>> h1 = http.client.HTTPConnection(‘so.xxxx.com’,80)
>>> h1
<http.client.HTTPConnection object at 0x0199FD70>
>>> http.client.HTTPConnection(‘www.python.org’)
<http.client.HTTPConnection object at 0x0199FD90>
>>> data.getcode()
200
>>> data.read()
b'”\\u94fe\\u63a5\\u5931\\u8d25!”‘
>>> data.read().decode(‘urf-8’)

>>> print(data.read().decode(‘urf-8’))

>>> print(data.read().undecode())
Traceback (most recent call last):
File “<pyshell#74>”, line 1, in <module>
print(data.read().undecode())
AttributeError: ‘bytes’ object has no attribute ‘undecode’
>>> import json
>>> json.loads(data.read())
Traceback (most recent call last):
File “<pyshell#76>”, line 1, in <module>
json.loads(data.read())
File “D:\python3.4\lib\json\__init__.py”, line 312, in loads
s.__class__.__name__))
TypeError: the JSON object must be str, not ‘bytes’
>>> print(data.read())
b”
>>> data = urllib.request.urlopen(‘http://so.xxxx.com/api.php?key=1451010286&ID=36308a5755eb111781ef72ae1feec14c&code=201510636248&type=2&state=1’)
>>> data.read()
b'”\\u94fe\\u63a5\\u5931\\u8d25!”‘
>>> data.read()
b”
>>> data = urllib.request.urlopen(‘http://so.xxxx.com/api.php?key=1451010286&ID=36308a5755eb111781ef72ae1feec14c&code=201510636248&type=2&state=1’)
>>> json.loads(data.read())
Traceback (most recent call last):
File “<pyshell#82>”, line 1, in <module>
json.loads(data.read())
File “D:\python3.4\lib\json\__init__.py”, line 312, in loads
s.__class__.__name__))
TypeError: the JSON object must be str, not ‘bytes’
>>> data = urllib.request.urlopen(‘http://so.xxxx.com/api.php?key=1451010286&ID=36308a5755eb111781ef72ae1feec14c&code=201510636248&type=2&state=1’)
>>> js = data.read()
>>> js
b'”\\u94fe\\u63a5\\u5931\\u8d25!”‘
>>> js
b'”\\u94fe\\u63a5\\u5931\\u8d25!”‘
>>> json.loads(js)
Traceback (most recent call last):
File “<pyshell#87>”, line 1, in <module>
json.loads(js)
File “D:\python3.4\lib\json\__init__.py”, line 312, in loads
s.__class__.__name__))
TypeError: the JSON object must be str, not ‘bytes’
>>> js.encode()
Traceback (most recent call last):
File “<pyshell#88>”, line 1, in <module>
js.encode()
AttributeError: ‘bytes’ object has no attribute ‘encode’
>>> u = unicode(“人生苦短”)
Traceback (most recent call last):
File “<pyshell#89>”, line 1, in <module>
u = unicode(“人生苦短”)
NameError: name ‘unicode’ is not defined
>>> echo data
SyntaxError: invalid syntax
>>> print(js)
b'”\\u94fe\\u63a5\\u5931\\u8d25!”‘
>>> js.decode()
‘”\\u94fe\\u63a5\\u5931\\u8d25!”‘
>>> e.decode(‘utf-8’)
Traceback (most recent call last):
File “<pyshell#93>”, line 1, in <module>
e.decode(‘utf-8’)
NameError: name ‘e’ is not defined
>>> js.decode(‘utf-8’)
‘”\\u94fe\\u63a5\\u5931\\u8d25!”‘
>>> u= ‘你好’
>>> u.encode()
b’\xe4\xbd\xa0\xe5\xa5\xbd’
>>> u.decode
Traceback (most recent call last):
File “<pyshell#97>”, line 1, in <module>
u.decode
AttributeError: ‘str’ object has no attribute ‘decode’
>>> u.decode()
Traceback (most recent call last):
File “<pyshell#98>”, line 1, in <module>
u.decode()
AttributeError: ‘str’ object has no attribute ‘decode’
>>> print(u)
你好
>>> u='”\u94fe\u63a5\u5931\u8d25!”‘
>>> u.decode()
Traceback (most recent call last):
File “<pyshell#101>”, line 1, in <module>
u.decode()
AttributeError: ‘str’ object has no attribute ‘decode’
>>> ss = js.encode(‘utf8’)
Traceback (most recent call last):
File “<pyshell#102>”, line 1, in <module>
ss = js.encode(‘utf8’)
AttributeError: ‘bytes’ object has no attribute ‘encode’
>>> print(js)
b'”\\u94fe\\u63a5\\u5931\\u8d25!”‘
>>> ss =js.encode()
Traceback (most recent call last):
File “<pyshell#104>”, line 1, in <module>
ss =js.encode()
AttributeError: ‘bytes’ object has no attribute ‘encode’
>>> s =b'”\\u94fe\\u63a5\\u5931\\u8d25!”‘
>>> type(s)
<class ‘bytes’>
>>> str(s)
‘b\'”\\\\u94fe\\\\u63a5\\\\u5931\\\\u8d25!”\”
>>> s =u'”\\u94fe\\u63a5\\u5931\\u8d25!”‘
>>> s.encode()
b'”\\u94fe\\u63a5\\u5931\\u8d25!”‘
>>> ss =s.encode()
>>> x = json.loads(‘{“foo”:”%s”}’ % ss)
Traceback (most recent call last):
File “<pyshell#111>”, line 1, in <module>
x = json.loads(‘{“foo”:”%s”}’ % ss)
File “D:\python3.4\lib\json\__init__.py”, line 318, in loads
return _default_decoder.decode(s)
File “D:\python3.4\lib\json\decoder.py”, line 343, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File “D:\python3.4\lib\json\decoder.py”, line 359, in raw_decode
obj, end = self.scan_once(s, idx)
ValueError: Expecting ‘,’ delimiter: line 1 column 12 (char 11)
>>> x = json.loads(‘{“foo”:”%s”}’ , ss)
>>> print (x[‘foo’])
%s
>>> x = json.loads(‘{“foo”:”%s”}’ from( ss))
SyntaxError: invalid syntax
>>> x = json.loads(‘{“foo”:”%s”}’ format( ss))
SyntaxError: invalid syntax
>>> x = json.loads(‘{“foo”:”%s”}’.format( ss))
Traceback (most recent call last):
File “<pyshell#116>”, line 1, in <module>
x = json.loads(‘{“foo”:”%s”}’.format( ss))
KeyError: ‘”foo”‘
>>> x = json.loads(‘{“foo”:”{0}”}’.format( ss))
Traceback (most recent call last):
File “<pyshell#117>”, line 1, in <module>
x = json.loads(‘{“foo”:”{0}”}’.format( ss))
KeyError: ‘”foo”‘
>>> x = json.loads(‘{“foo”:”%s”}’ %(ss))
Traceback (most recent call last):
File “<pyshell#118>”, line 1, in <module>
x = json.loads(‘{“foo”:”%s”}’ %(ss))
File “D:\python3.4\lib\json\__init__.py”, line 318, in loads
return _default_decoder.decode(s)
File “D:\python3.4\lib\json\decoder.py”, line 343, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File “D:\python3.4\lib\json\decoder.py”, line 359, in raw_decode
obj, end = self.scan_once(s, idx)
ValueError: Expecting ‘,’ delimiter: line 1 column 12 (char 11)
>>> x = json.loads(‘{“foo”:”\\u94fe\\u63a5\\u5931\\u8d25!”}’)
>>> x
{‘foo’: ‘链接失败!’}
>>> x = json.loads(‘{“foo”:’+ss+’}’)
Traceback (most recent call last):
File “<pyshell#121>”, line 1, in <module>
x = json.loads(‘{“foo”:’+ss+’}’)
TypeError: Can’t convert ‘bytes’ object to str implicitly
>>> x = json.loads(‘{“foo”:’+str(ss)+’}’)
Traceback (most recent call last):
File “<pyshell#122>”, line 1, in <module>
x = json.loads(‘{“foo”:’+str(ss)+’}’)
File “D:\python3.4\lib\json\__init__.py”, line 318, in loads
return _default_decoder.decode(s)
File “D:\python3.4\lib\json\decoder.py”, line 343, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File “D:\python3.4\lib\json\decoder.py”, line 361, in raw_decode
raise ValueError(errmsg(“Expecting value”, s, err.value)) from None
ValueError: Expecting value: line 1 column 8 (char 7)
>>> str(ss)
‘b\'”\\\\u94fe\\\\u63a5\\\\u5931\\\\u8d25!”\”
>>> x = json.loads(‘{“foo”:{0}}’.format(ss))
Traceback (most recent call last):
File “<pyshell#124>”, line 1, in <module>
x = json.loads(‘{“foo”:{0}}’.format(ss))
KeyError: ‘”foo”‘
>>> x = json.loads(‘{“foo”:{0}’.format(ss))
Traceback (most recent call last):
File “<pyshell#125>”, line 1, in <module>
x = json.loads(‘{“foo”:{0}’.format(ss))
ValueError: unmatched ‘{‘ in format spec
>>> x = ‘{“foo”:{0}}’.format(ss)
Traceback (most recent call last):
File “<pyshell#126>”, line 1, in <module>
x = ‘{“foo”:{0}}’.format(ss)
KeyError: ‘”foo”‘
>>> x = ‘{“foo”:{0}’.format(ss)
Traceback (most recent call last):
File “<pyshell#127>”, line 1, in <module>
x = ‘{“foo”:{0}’.format(ss)
ValueError: unmatched ‘{‘ in format spec
>>> x = ‘”foo”:{0}}’.format(ss)
Traceback (most recent call last):
File “<pyshell#128>”, line 1, in <module>
x = ‘”foo”:{0}}’.format(ss)
ValueError: Single ‘}’ encountered in format string
>>> x = ‘”foo”:{0}’.format(ss)
>>> x
‘”foo”:b\'”\\\\u94fe\\\\u63a5\\\\u5931\\\\u8d25!”\”
>>> json.loads(‘{‘+x+’}’)
Traceback (most recent call last):
File “<pyshell#131>”, line 1, in <module>
json.loads(‘{‘+x+’}’)
File “D:\python3.4\lib\json\__init__.py”, line 318, in loads
return _default_decoder.decode(s)
File “D:\python3.4\lib\json\decoder.py”, line 343, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File “D:\python3.4\lib\json\decoder.py”, line 361, in raw_decode
raise ValueError(errmsg(“Expecting value”, s, err.value)) from None
ValueError: Expecting value: line 1 column 8 (char 7)
>>> j = ‘{‘+x+’}’
>>> j
‘{“foo”:b\'”\\\\u94fe\\\\u63a5\\\\u5931\\\\u8d25!”\’}’
>>> x = json.loads(‘{“foo”:”\\u94fe\\u63a5\\u5931\\u8d25!”}’)

SyntaxError: unexpected indent
>>> x = json.loads(‘{“foo”:”\\u94fe\\u63a5\\u5931\\u8d25!”}’)
>>> data urllib.request.urlopen(‘c8.ipvb.cn/index/ceshi’)
SyntaxError: invalid syntax
>>> data = urllib.request.urlopen(‘c8.ipvb.cn/index/ceshi’)
Traceback (most recent call last):
File “<pyshell#137>”, line 1, in <module>
data = urllib.request.urlopen(‘c8.ipvb.cn/index/ceshi’)
File “D:\python3.4\lib\urllib\request.py”, line 161, in urlopen
return opener.open(url, data, timeout)
File “D:\python3.4\lib\urllib\request.py”, line 448, in open
req = Request(fullurl, data)
File “D:\python3.4\lib\urllib\request.py”, line 266, in __init__
self.full_url = url
File “D:\python3.4\lib\urllib\request.py”, line 292, in full_url
self._parse()
File “D:\python3.4\lib\urllib\request.py”, line 321, in _parse
raise ValueError(“unknown url type: %r” % self.full_url)
ValueError: unknown url type: ‘c8.ipvb.cn/index/ceshi’
>>> data urllib.request.urlopen(‘http://c8.ipvb.cn/index/ceshi’)
SyntaxError: invalid syntax
>>> data = urllib.request.urlopen(‘http://c8.ipvb.cn/index/ceshi’)
>>> cd = data.read()
>>> cd
b'{“id”:1,”user”:3}’
>>> json.loads(cd)
Traceback (most recent call last):
File “<pyshell#142>”, line 1, in <module>
json.loads(cd)
File “D:\python3.4\lib\json\__init__.py”, line 312, in loads
s.__class__.__name__))
TypeError: the JSON object must be str, not ‘bytes’
>>> json.loads(cd.encode())
Traceback (most recent call last):
File “<pyshell#143>”, line 1, in <module>
json.loads(cd.encode())
AttributeError: ‘bytes’ object has no attribute ‘encode’
>>> cd.encode()
Traceback (most recent call last):
File “<pyshell#144>”, line 1, in <module>
cd.encode()
AttributeError: ‘bytes’ object has no attribute ‘encode’
>>> cd
b'{“id”:1,”user”:3}’
>>> def nexmo_sendsms(api_key, api_secret, sender, receiver, body):
“””
Sends a message using Nexmo.

:param api_key: Nexmo provided api key
:param api_secret: Nexmo provided secrety key
:param sender: The number used to send the message
:param receiver: The number the message is addressed to
:param body: The message body
:return: Returns the msgid received back from Nexmo after message has been sent.
“””
msg = {
‘api_key’: api_key,
‘api_secret’: api_secret,
‘from’: sender,
‘to’: receiver,
‘text’: body
}
nexmo_url = ‘https://rest.nexmo.com/sms/json’
data = urllib.parse.urlencode(msg)
binary_data = data.encode(‘utf8’)
req = urllib.request.Request(nexmo_url, binary_data)
response = urllib.request.urlopen(req)
result = json.loads(response.readall().decode(‘utf-8’))
return result[‘messages’][0][‘message-id’]

>>> nexmo_url= ‘http://c8.ipvb.cn/index/ceshi’
>>> req = urllib.request.Request(nexmo_url)
>>> response = urllib.request.urlopen(req)
>>> result = json.loads(response.readall().decode(‘utf-8’))
>>> print(result)
{‘id’: 1, ‘user’: 3}
>>> resu
Traceback (most recent call last):
File “<pyshell#153>”, line 1, in <module>
resu
NameError: name ‘resu’ is not defined
>>> result.encode()
Traceback (most recent call last):
File “<pyshell#154>”, line 1, in <module>
result.encode()
AttributeError: ‘dict’ object has no attribute ‘encode’
>>> result[‘id’]
1
>>> def get_shuj(url):
nexmo_url= url
req = urllib.request.Request(nexmo_url)
response = urllib.request.urlopen(req)
result = json.loads(response.readall().decode(‘utf-8’))
return result

>>> h = get_shuj(‘http://so.xxxx.com/api.php?key=1451010286&ID=36308a5755eb111781ef72ae1feec14c&code=201510636248&type=2&state=1’)
>>> h
‘链接失败!’
>>> def ceshi():
for i in range(1,100)

SyntaxError: invalid syntax
>>> def ceshi():
for i in range(1,100):
print(i)
sleep(2)
>>> ceshi()
1
Traceback (most recent call last):
File “<pyshell#168>”, line 1, in <module>
ceshi()
File “<pyshell#167>”, line 4, in ceshi
sleep(2)
NameError: name ‘sleep’ is not defined
>>> import time
>>> ceshi()
1
Traceback (most recent call last):
File “<pyshell#170>”, line 1, in <module>
ceshi()
File “<pyshell#167>”, line 4, in ceshi
sleep(2)
NameError: name ‘sleep’ is not defined
>>> def ceshi():
for i in range(1,100):
print(i)
time.sleep(2)
>>> ceshi()
1
2
3
4
Traceback (most recent call last):
File “<pyshell#173>”, line 1, in <module>
ceshi()
File “<pyshell#172>”, line 4, in ceshi
time.sleep(2)
KeyboardInterrupt
>>> apiurl=’http://so.xxxx.com/api.php?KEY=’
>>> api_key = ‘SDljksdfAS,*[];/’
>>> key = time.time()
>>> api_key = md5(md5(api_key)+str(key))
Traceback (most recent call last):
File “<pyshell#177>”, line 1, in <module>
api_key = md5(md5(api_key)+str(key))
NameError: name ‘md5’ is not defined
>>> import md5
Traceback (most recent call last):
File “<pyshell#178>”, line 1, in <module>
import md5
ImportError: No module named ‘md5’
>>> import md5
Traceback (most recent call last):
File “<pyshell#179>”, line 1, in <module>
import md5
ImportError: No module named ‘md5’
>>> import hashlib
>>> m2 = hashlib.md5()
>>> def md5():
m2 = hashlib.md5()
m2.update(src)
return m2.hexdigest()

>>> def md5(src):
m2 = hashlib.md5()
m2.update(src)
return m2.hexdigest()

>>> api_key = md5(md5(api_key)+str(key))
Traceback (most recent call last):
File “<pyshell#187>”, line 1, in <module>
api_key = md5(md5(api_key)+str(key))
File “<pyshell#186>”, line 3, in md5
m2.update(src)
TypeError: Unicode-objects must be encoded before hashing
>>> str(key)
‘1451029066.366347’
>>> time.ctime()
‘Fri Dec 25 15:43:39 2015′
>>> key = int(time.time())
>>> key
1451029453
>>> m2 = hashlib.md5()
>>> m2.update(str(key))
Traceback (most recent call last):
File “<pyshell#193>”, line 1, in <module>
m2.update(str(key))
TypeError: Unicode-objects must be encoded before hashing
>>> m2.update(’22’)
Traceback (most recent call last):
File “<pyshell#194>”, line 1, in <module>
m2.update(’22’)
TypeError: Unicode-objects must be encoded before hashing
>>> m2 = hashlib.md5()
>>> m2.update(’22’)
Traceback (most recent call last):
File “<pyshell#196>”, line 1, in <module>
m2.update(’22’)
TypeError: Unicode-objects must be encoded before hashing
>>> def md5(src):
m2 = hashlib.md5()
m2.update(src.encode(‘utf-8’))
return m2.hexdigest()

>>> md5(‘222’)
‘bcbe3365e6ac95ea2c0343a2395834dd’
>>> api_key = md5(md5(api_key)+str(key))
>>> api_key
‘882f6e82b39fd9910a7cbbeaa49b2174′
>>> def api_zl(state=1):
if state:
url =apiurl+str(key)+’&ID=’+api_key+’&code=’+zl+’&type=’+sedtype
else:
url =apiurl+str(key)+’&ID=’+api_key+’&code=’+zl+’&type=’+sedtype+’&state=1’
return url

>>> api_zl
<function api_zl at 0x019F6ED0>
>>> api_zl()
Traceback (most recent call last):
File “<pyshell#210>”, line 1, in <module>
api_zl()
File “<pyshell#208>”, line 3, in api_zl
url =apiurl+str(key)+’&ID=’+api_key+’&code=’+zl+’&type=’+sedtype
NameError: name ‘zl’ is not defined
>>> state =0
>>> if state:
url =apiurl+str(key)+’&ID=’+api_key+’&code=’+zl+’&type=’+sedtype
else:
url =apiurl+str(key)+’&ID=’+api_key+’&code=’+zl+’&type=’+sedtype+’&state=1′

SyntaxError: unindent does not match any outer indentation level
>>> if state:
url =apiurl+str(key)+’&ID=’+api_key+’&code=’+zl+’&type=’+sedtype
else:
url =apiurl+str(key)+’&ID=’+api_key+’&code=’+zl+’&type=’+sedtype+’&state=1′
Traceback (most recent call last):
File “<pyshell#214>”, line 4, in <module>
url =apiurl+str(key)+’&ID=’+api_key+’&code=’+zl+’&type=’+sedtype+’&state=1′
NameError: name ‘zl’ is not defined
>>> zl = ‘201520353264.5’
>>> if state:
url =apiurl+str(key)+’&ID=’+api_key+’&code=’+zl+’&type=’+sedtype
else:
url =apiurl+str(key)+’&ID=’+api_key+’&code=’+zl+’&type=’+sedtype+’&state=1′
Traceback (most recent call last):
File “<pyshell#217>”, line 4, in <module>
url =apiurl+str(key)+’&ID=’+api_key+’&code=’+zl+’&type=’+sedtype+’&state=1′
NameError: name ‘sedtype’ is not defined
>>> sedtype =1
>>> if state:
url =apiurl+str(key)+’&ID=’+api_key+’&code=’+zl+’&type=’+sedtype
else:
url =apiurl+str(key)+’&ID=’+api_key+’&code=’+zl+’&type=’+sedtype+’&state=1′
Traceback (most recent call last):
File “<pyshell#220>”, line 4, in <module>
url =apiurl+str(key)+’&ID=’+api_key+’&code=’+zl+’&type=’+sedtype+’&state=1′
TypeError: Can’t convert ‘int’ object to str implicitly
>>> if state:
url =apiurl+str(key)+’&ID=’+api_key+’&code=’+zl+’&type=’+str(sedtype)
else:
url =apiurl+str(key)+’&ID=’+api_key+’&code=’+zl+’&type=’+str(sedtype)+’&state=1′
>>> url
‘http://so.xxxx.com/api.php?KEY=1451029453&ID=882f6e82b39fd9910a7cbbeaa49b2174&code=201520353264.5&type=1&state=1’
>>> url
‘http://so.xxxx.com/api.php?KEY=1451029453&ID=882f6e82b39fd9910a7cbbeaa49b2174&code=201520353264.5&type=1&state=1’
>>> url
‘http://so.xxxx.com/api.php?KEY=1451029453&ID=882f6e82b39fd9910a7cbbeaa49b2174&code=201520353264.5&type=1&state=1’
>>> key = int(time.time())
>>> url
‘http://so.xxxx.com/api.php?KEY=1451029453&ID=882f6e82b39fd9910a7cbbeaa49b2174&code=201520353264.5&type=1&state=1’
>>> get_shuj(url)
{‘sqrdz’: ‘518000|广东省深圳市福田区车公庙深南大道南侧杭钢富春商务大厦1718-1720’, ‘gkwb’: ”, ‘dlr’: ‘廉红果 ;\r\n温洁’, ‘sqh’: ‘201520353264’, ‘type’: ‘2’, ‘zlstate’: ‘有效专利’, ‘ipc’: ‘G04G21/00;G04G21/04;G08B21/02’, ‘gbr’: ‘1442332800’, ‘zlc’: ‘5’, ‘gkr’: ‘1442332800’, ‘gbh’: ”, ‘dlgs’: ‘深圳市合道英联专利事务所(普通合伙)44309’, ‘sms’: ”, ‘sqwb’: ”, ‘sqri’: ‘1432742400’, ‘zlmc’: ‘智能手表’, ‘flzt’: ”, ‘zhaiyao’: ‘本实用新型公开了一种智能手表,其包括:用于显示时间的时钟模块,其特征在于,用于获取智能手表当前所在的坐标位置并输出坐标信息的定位模块,用于接收所述坐标信息并将该坐标信息与预设的参考范围进行比较以输出报警信号的控制模块,用于与智能终端进行通信并将所述控制模块输出的坐标信息及报警信号传送至所述智能终端的通信模块;其中,所述时钟模块与所述控制模块连接,所述定位模块的坐标信息输出端与所述控制模块的坐标信息输入端连接,所述控制模块的输出端与所述通信模块的输入端连接,所述通信模块与所述智能终端进行通信。’, ‘qlyq’: ”, ‘zqx’: ‘一种智能手表,包括:用于显示时间的时钟模块,其特征在于,还包括:用于获取智能手表当前所在的坐标位置并输出坐标信息的定位模块,用于接收所述坐标信息并将该坐标信息与预设的参考范围进行比较以输出报警信号的控制模块,用于与智能终端进行通信并将所述控制模块输出的坐标信息及报警信号传送至所述智能终端的通信模块;其中,所述时钟模块与所述控制模块连接,所述定位模块的坐标信息输出端与所述控制模块的坐标信息输入端连接,所述控制模块的输出端与所述通信模块的输入端连接,所述通信模块与所述智能终端进行通信。’, ‘fmr’: ‘张志琼’, ‘gkh’: ‘204650150U’, ‘sqren’: ‘深圳市科乐科技有限公司’, ‘tongzu’: ”}
>>> zl = ‘201520715832’
>>> def api_zl(self,zl=0,sedtype=1,state=1):
apiurl=’http://so.xxxx.com/api.php?KEY=’
api_key = ‘SDljksdfAS,*[];/’
key = int(time.time())
api_key = md5(md5(api_key)+str(key));
if state:
url =apiurl+str(key)+’&ID=’+api_key+’&code=’+str(zl)+’&type=’+str(sedtype)
else:
url =apiurl+str(key)+’&ID=’+api_key+’&code=’+str(zl)+’&type=’+str(sedtype)+’&state=1′

return get_shuj(url)
>>> def api_zl(zl=0,sedtype=1,state=1):
apiurl=’http://so.xxxx.com/api.php?KEY=’
api_key = ‘SDljksdfAS,*[];/’
key = int(time.time())
api_key = md5(md5(api_key)+str(key));
if state:
url =apiurl+str(key)+’&ID=’+api_key+’&code=’+str(zl)+’&type=’+str(sedtype)
else:
url =apiurl+str(key)+’&ID=’+api_key+’&code=’+str(zl)+’&type=’+str(sedtype)+’&state=1′

return get_shuj(url)
>>> api_zl(201520715832)
Traceback (most recent call last):
File “<pyshell#234>”, line 1, in <module>
api_zl(201520715832)
File “<pyshell#233>”, line 11, in api_zl
return get_shuj(url)
File “<pyshell#159>”, line 5, in get_shuj
result = json.loads(response.readall().decode(‘utf-8’))
File “D:\python3.4\lib\json\__init__.py”, line 318, in loads
return _default_decoder.decode(s)
File “D:\python3.4\lib\json\decoder.py”, line 343, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File “D:\python3.4\lib\json\decoder.py”, line 361, in raw_decode
raise ValueError(errmsg(“Expecting value”, s, err.value)) from None
ValueError: Expecting value: line 1 column 1 (char 0)
>>> api_zl(201230389891)
{‘sqrdz’: ‘518000|广东省深圳市宝安62区富强大厦218’, ‘gkwb’: ”, ‘dlr’: ‘朱思全’, ‘sqh’: ‘201230389891’, ‘type’: ‘3’, ‘zlstate’: ‘有效专利’, ‘ipc’: ’26-02′, ‘gbr’: ‘0’, ‘zlc’: ‘6’, ‘gkr’: ‘1358870400’, ‘gbh’: ”, ‘dlgs’: ‘深圳市合道英联专利事务所(普通合伙)44309’, ‘sms’: ”, ‘sqwb’: ”, ‘sqri’: ‘1345046400’, ‘zlmc’: ‘太阳能手电筒(椭圆形)’, ‘flzt’: ”, ‘zhaiyao’: ”, ‘qlyq’: ”, ‘zqx’: ‘法律状态公告日法律状态法律状态详情2013-01-23有效专利授权’, ‘fmr’: ‘傅伟革’, ‘gkh’: ‘302301446S’, ‘sqren’: ‘傅伟革’, ‘tongzu’: ”}
>>> api_zl(201230389891,1,0)
{‘sqrdz’: ‘518000|广东省深圳市宝安62区富强大厦218’, ‘gkwb’: ”, ‘dlr’: ‘朱思全’, ‘sqh’: ‘201230389891’, ‘type’: ‘3’, ‘zlstate’: ‘有效专利’, ‘ipc’: ’26-02′, ‘gbr’: ‘0’, ‘zlc’: ‘6’, ‘gkr’: ‘1358870400’, ‘gbh’: ”, ‘dlgs’: ‘深圳市合道英联专利事务所(普通合伙)44309’, ‘sms’: ”, ‘sqwb’: ”, ‘sqri’: ‘1345046400’, ‘zlmc’: ‘太阳能手电筒(椭圆形)’, ‘flzt’: ”, ‘zhaiyao’: ”, ‘qlyq’: ”, ‘zqx’: ‘法律状态公告日法律状态法律状态详情2013-01-23有效专利授权’, ‘fmr’: ‘傅伟革’, ‘gkh’: ‘302301446S’, ‘sqren’: ‘傅伟革’, ‘tongzu’: ”}
>>> print(__init__)
Traceback (most recent call last):
File “<pyshell#237>”, line 1, in <module>
print(__init__)
NameError: name ‘__init__’ is not defined
>>> print(__path__)
Traceback (most recent call last):
File “<pyshell#238>”, line 1, in <module>
print(__path__)
NameError: name ‘__path__’ is not defined
>>>
>>>
>>>
>>>
>>>
>>> api_zl(201230389891,1,0)
{‘sqrdz’: ‘518000|广东省深圳市宝安62区富强大厦218’, ‘gkwb’: ”, ‘dlr’: ‘朱思全’, ‘sqh’: ‘201230389891’, ‘type’: ‘3’, ‘zlstate’: ‘有效专利’, ‘ipc’: ’26-02′, ‘gbr’: ‘0’, ‘zlc’: ‘6’, ‘gkr’: ‘1358870400’, ‘gbh’: ”, ‘dlgs’: ‘深圳市合道英联专利事务所(普通合伙)44309’, ‘sms’: ”, ‘sqwb’: ”, ‘sqri’: ‘1345046400’, ‘zlmc’: ‘太阳能手电筒(椭圆形)’, ‘flzt’: ”, ‘zhaiyao’: ”, ‘qlyq’: ”, ‘zqx’: ‘法律状态公告日法律状态法律状态详情2013-01-23有效专利授权’, ‘fmr’: ‘傅伟革’, ‘gkh’: ‘302301446S’, ‘sqren’: ‘傅伟革’, ‘tongzu’: ”}
>>> class hello:
def __init__(slef,name):
slef._name=name
>>> h = hello(‘123’)
>>> class hello:
def __init__(slef,name):
slef._name=name
def dayin(slef):
print(slef._name)
>>> h = hello(‘123’)
>>> h.
SyntaxError: invalid syntax
>>> h.dayin()
123
>>>

发表评论

您的电子邮箱地址不会被公开。

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据