<< < 1 2 3 4 5 > >>   Sort: Rank

What Is Python Module 'json'
What Is Python module "json"? "json" is a Python internal module that allows to encode and code JSON strings. Here are some important properties and functions provided by the "json" module: &gt;&gt;&gt; import json &gt;&gt;&gt; json.dumps() # serializes a given object into a ...
2018-10-13, 1021👍, 0💬

Extending json.JSONEncoder Class
How to extend json.JSONEncoder class? I want to encode other Python data types to JSON. If you encode your own data types to JSON strings, you need to extend the json.JSONEncoder class and override the default() function. The following Python example shows you how to extend json.JSONEncoder class to...
2018-10-08, 3082👍, 0💬

json.loads() - Loading JSON into Object
How to load (or decode, deserialize) a JSON string into a Python object using json.loads()? The json.loads() function allows you to load (or decode, deserialize) JSON strings (str, bytes or bytearray types) into Pythong objects: json.loads(s, *, encoding=None, cls=None, object_hook=None, parse_float...
2018-10-08, 1942👍, 0💬

What Is json.JSONEncoder Class
What Is json.JSONEncoder Class? json.JSONEncoder class is the underlying class that supports json.dumps() functions. The following Python example shows you how to use json.JSONEncoder class to perform the same JSON encoding job as json.dumps function: &gt;&gt;&gt; import json &gt;&am...
2018-10-08, 1692👍, 0💬

Dumping JSON Output to File
How to dump (or encode, serialize) a Python object into file or an output stream as a JSON string using json.dump()? json.dump(o,fp,...) function performs the same job as json.dumps(o,...) except that it directs the JSON string to the output stream of a given file pointer. Here is a Python example t...
2018-10-08, 1212👍, 0💬

Generating JSON Strings in Pretty Format
How to generate JSON strings in pretty format using json.dumps()? You can control the JSON output string format with "indent", "separators" and "sort_keys" arguments of the json.dumps() function: Here is a Python example that generates a pretty formatted JSON string with property keys sorted: &g...
2018-10-08, 1153👍, 0💬

http.client.HTTPResponse Objects
What properties and functions are supported on http.client.HTTPResponse objects? If you get an http.client.HTTPResponse object from a urlopen() function call, you should be able use the following properties and functions: &gt;&gt;&gt; r = urllib.request.urlopen('http:/ /httpbin.org/get')...
2018-09-24, 7377👍, 0💬

json.tool - JSON Pretty-Print Tool
What is json.tool? Can I use it to convert a JSON string a pretty-print format? json.tool is a special internal executable module - a module with main() so you can run it as Python script. When you run json.tool, (or json.module.main()), it will read a JSON string from the stand input and write the ...
2018-09-24, 2069👍, 0💬

Sending an HTTP Request with 'urllib.request'
How to send an HTTP request using the "urllib.request" module? To send an HTTP request to the Internet, you can use the urllib.request.urlopen() function as described below: r = urllib.request.urlopen(url, data=None, [timeout, ]*, cafile=None, capath=None, cadefault=False, context=None) where: url c...
2018-09-24, 1535👍, 0💬

'urllib' Module - Internet Communication
Where to find tutorials on Python "urllib" Module? Here is a list of tutorials to answer many frequently asked questions compiled by FYIcenter.com team on Python "urllib" Module. What Is Python Module 'urllib' Sending an HTTP Request with 'urllib.request' http.client.HTTPResponse Objects HTTP POST w...
2018-09-24, 1061👍, 0💬

What Is Python Module 'urllib'
What Is Python module "urllib"? "urllib" is a Python internal module that allows you to communicate with Internet resources that are represented by URLs. Two main Internet protocols are supported: HTTP and FTP. The current version of "urllib" module is divided into 4 sub-modules: urllib.request - fo...
2018-09-24, 1025👍, 0💬

Using urllib.parse.urlencode()
How to use urllib.parse.urlencode() function to encode HTTP POST data? My form data has special characters. If your form data has spaces, equal signs, and other special characters, you need to call urllib.parse.urlencode() to encode it before passing it to the urlopen() function. The urlencode() fun...
2018-09-13, 3388👍, 0💬

Sending FTP Request with urllib.request.urlopen
How to send an FTP request with the urllib.request.urlopen() function? If an FTP server supports anonymous access, you can send an FTP request to retrieve a directory list, or download a file using the urllib.request.urlopen() function: Here is a Python example on how to get a directory list from an...
2018-09-13, 3039👍, 0💬

Using urllib.request.Request Object
How to use the urllib.request.Request object to build more complex HTTP request? The urllib.request.urlopen() function can take a urllib.request.Request object to let you building more complex HTTP requests. You can use the Request() constructor to build a Request object: q = urllib.request.Request(...
2018-09-13, 2929👍, 0💬

HTTP POST with urllib.request
How to send an HTTP POST request with urllib.request? I want to submit a form to a Website. To submit a form to a Website, you can use the urllib.request.urlopen() function with two arguments: r = urllib.request.urlopen(url, data) where: url can be a URL string or Request object data is request body...
2018-09-13, 1896👍, 0💬

urllib.request.Request Properties and Functions
What properties and functions are supported on urllib.request.Request objects? urllib.request.Request objects support the following properties and functions: &gt;&gt;&gt; q = urllib.request.Request(url) host # represents the host name of the url. type # represents the internet protocol t...
2018-09-13, 1567👍, 0💬

Installing 'requests' Module
How to install "requests" module? I am getting the "ModuleNotFoundError: No module named 'requests'" error. If you are getting the following error when running "import requests", you need to follow this tutorial to install the "requests" module. C:\fyicenter&gt;python Python 3.6.2 (v3.6.2:5fd33b...
2018-09-01, 1625👍, 0💬

What Is Python Module 'requests'
What Is Python module "requests"? "requests" is a Python external module that allows you to send organic, grass-fed HTTP/1.1 requests, without the need for manual labor. There’s no need to manually add query strings to your URLs, or to form-encode your POST data. Main features of "requests" module: ...
2018-09-01, 1395👍, 0💬

'requests' Module - HTTP for Humans
Where to find tutorials on Python "requests" Module? Here is a list of tutorials to answer many frequently asked questions compiled by FYIcenter.com team on Python "requests" Module. What Is Python Module 'requests' Installing 'requests' Module Sending an HTTP Request with 'requests' requests.models...
2018-09-01, 1304👍, 0💬

Sending an HTTP Request with 'requests'
How to send an HTTP request? I have the "requests" module installed now. The "requests" module provides 6 static functions to support 6 HTTP request types: &gt;&gt;&gt; r = requests.get(url) &gt;&gt;&gt; r = requests.post(url, data = {'key':'value'}) &gt;&gt;&gt; ...
2018-09-01, 1230👍, 0💬

Sending an HTTP POST Request
How to send an HTTP POST request? I want to submit a form to a Website. To submit a form to a Website, you can use the requests.post() function: &gt;&gt;&gt; r = requests.post(url, data = {'key':'value'}) The second argument 'data' is a 'dict' object contains of the list of form field na...
2018-08-14, 1687👍, 0💬

Accessing the HTTP Request Object
How to access the HTTP request from the HTTP response object? I want to see what was actually delivered to the server. To see what was actually delivered to the server, you can take the "request" property of the response object: &gt;&gt;&gt; r = requests.post() &gt;&gt;&gt; q...
2018-08-14, 1079👍, 0💬

'for ... in' Statement with List of Tuples
How to use "for ... in" statements with a list of tuples in Python code? Usually, "for ... in" statements are used with simple lists. But you can also use a "for ... in" statement with a list of tuples. In this case, you can put multiple looping variables inside the loop item: for (v1, v2, ... ) in ...
2018-08-14, 1460👍, 0💬

'@...' Function Decorators
What are function decorators in Python? A function decorator is shorthand notation to replace a function with a new version transformed by a wrapper function. A function decorator can be specified using the following syntax: @decorator_wrapper_function def func(): ... Above Python code is actually e...
2018-05-08, 1734👍, 0💬

<< < 1 2 3 4 5 > >>   Sort: Rank