PYTHONPATH
python -m myscript01 arg1 arg2
refer to:
https://stackoverflow.com/questions/18247333/pythonpath-on-linux
人,技术,生活。
PYTHONPATH
python -m myscript01 arg1 arg2
refer to:
https://stackoverflow.com/questions/18247333/pythonpath-on-linux
The upper operators have higher precedence than the lower.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | Grouping () Function call f() Slicing [index:index] Array subscription [] Bitwise NOT ~x Unary plus/minus +, - Mul/Div/Mod *, /, % Add/Sub +, - Bitwise shift <<, >> Bitwise AND & Bitwise XOR ^ Bitwise OR | Relation ==, !=, >, >=, <, <=, is, is not, in, not in not and or lambda |
refer to:
https://discuss.codechef.com/t/operator-precedence-table/14545
httpd.py
1 2 3 4 5 6 7 8 9 10 | from http.server import HTTPServer, SimpleHTTPRequestHandler handler = SimpleHTTPRequestHandler handler.extensions_map.update({ ".js": "application/javascript", }) server_address = ("", 8008) server = HTTPServer(server_address, handler) server.serve_forever() |
how to run
1 | python3 ./httpd.py |
出现此提示的原因是用@jit标注的函数内存在非数值运算语句。
比如下例中,time()函数和print()函数都不能出现在foo()函数中。正确写法为:
1 2 3 4 5 6 7 8 9 10 11 12 13 | import numba as nb import time @nb.jit def foo(x, y): s = 0 for i in range(x, y): s += i return s tt = time.time() print(foo(1, 100000000)) print('Time used: {} secs'.format(time.time() - tt)) |
xml
1 2 3 | from xml.dom.minidom import * with open('d:/xml.txt', 'r') as f: print(parseString(f.read()).toprettyxml()) |
json
1 | python -m json.tool d:\json.txt |
下载文件
1 2 3 4 | import requests resp = requests.get('http://file.url', headers={'User-Agent':'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'}) with open("aa.dat", "wb") as f: f.write(resp.content) |