Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

python

Python – TypeError: Object of type ‘int64’ is not JSON serializable

json does not recognize NumPy data types. Convert the number to a Python int before serializing the object:

Categories numpy Tags numpy, python

Open file in a relative location in Python

With this type of thing you need to be careful what your actual working directory is. For example, you may not run the script from the directory the file is in. In this case, you can’t just use a relative path by itself. If you are sure the file you want is in a subdirectory … Read more

Categories Python Tags file, path, python, relative-path

Which Python memory profiler is recommended? [closed]

guppy3 is quite simple to use. At some point in your code, you have to write the following: This gives you some output like this: You can also find out from where objects are referenced and get statistics about that, but somehow the docs on that are a bit sparse. There is a graphical browser as … Read more

Categories performance Tags memory-management, performance, profiling, python

What does -> mean in Python function definitions?

It’s a function annotation. In more detail, Python 2.x has docstrings, which allow you to attach a metadata string to various types of object. This is amazingly handy, so Python 3 extends the feature by allowing you to attach metadata to functions describing their parameters and return values. There’s no preconceived use case, but the PEP … Read more

Categories Python Tags annotations, function-definition, python, python-3.x

Shuffle an array with python, randomize array item order with python

Categories Python Tags arrays, python, random, shuffle

Where does this come from: -*- coding: utf-8 -*-

This way of specifying the encoding of a Python file comes from PEP 0263 – Defining Python Source Code Encodings. It is also recognized by GNU Emacs (see Python Language Reference, 2.1.4 Encoding declarations), though I don’t know if it was the first program to use that syntax.

Categories Python Tags emacs, encoding, file, python, text

What is the Python 3 equivalent of “python -m SimpleHTTPServer”

From the docs: The SimpleHTTPServer module has been merged into http.server in Python 3.0. The 2to3 tool will automatically adapt imports when converting your sources to 3.0. So, your command is python -m http.server, or depending on your installation, it can be:

Categories Python Tags httpserver, python, python-3.x, simplehttpserver

Remove all occurrences of a value from a list?

Functional approach: Python 3.x or Python 2.x

Categories Python Tags list, python

AttributeError: ‘datetime’ module has no attribute ‘strptime’

If I had to guess, you did this: at the top of your code. This means that you have to do this: to access the strptime method. Or, you could change the import statement to this: and access it as you are. The people who made the datetime module also named their class datetime:

Categories Python Tags class, python, python-2.7

How to load a tsv file into a Pandas DataFrame?

The .read_csv function does what you want: If you have a header, you can pass header=0. Note: Prior 17.0, pd.DataFrame.from_csv was used (it is now deprecated and the .from_csv documentation link redirects to the page for pd.read_csv).

Categories Python Tags csv, pandas, python
Older posts
Newer posts
← Previous Page1 … Page169 Page170 Page171 … Page306 Next →
+ More

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Post Navigation Elementor
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • WPFacet multiple loop displaying duplicate content
  • Get the name of the template/*html file used
  • Fix: WordPress.DB.PreparedSQL.NotPrepared Plugin Check (PCP)
  • Removing unnecessary CSS and JS code from wp_head()
  • hexagonal image gallery. Am I on the right track? [closed]
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
© 2026 Read For Learn
Next Page »
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress