Skip to content

Magenaut

  • Home
  • Topics
    • Notes
    • Tutorial
    • Bug fixing
    • Extension
    • Server
  • Q&A
  • Privacy Policy
  • About

formatting

String formatting in Python

August 21, 2022 by Magenaut

I want to do something like String.Format("[{0}, {1}, {2}]", 1, 2, 3) which returns:

Categories Python, Q&A Tags formatting, python, string Leave a comment

Currency formatting in Python

August 20, 2022 by Magenaut

I am looking to format a number like 188518982.18 to £188,518,982.18 using Python.

Categories Python, Q&A Tags currency, formatting, python Leave a comment

Pandas: Setting no. of max rows

August 19, 2022 by Magenaut

I have a problem viewing the following DataFrame:

Categories Python, Q&A Tags formatting, ipython-notebook, pandas, python Leave a comment

Format floats with standard json module

August 18, 2022 by Magenaut

I am using the standard json module in python 2.6 to serialize a list of floats. However, I’m getting results like this:

Categories Python, Q&A Tags floating-point, formatting, json, python Leave a comment

Convert to binary and keep leading zeros

August 18, 2022 by Magenaut

I’m trying to convert an integer to binary using the bin() function in Python. However, it always removes the leading zeros, which I actually need, such that the result is always 8-bit:

Categories Python, Q&A Tags binary, bitwise-operators, formatting, python Leave a comment

Formatting timedelta objects

August 18, 2022 by Magenaut

But I was wondering if I can do it in a single line using any date time function like strftime.

Categories Python, Q&A Tags datetime, formatting, python Leave a comment

Easy pretty printing of floats?

August 17, 2022 by Magenaut

I have a list of floats. If I simply print it, it shows up like this:

Categories Python, Q&A Tags floating-point, formatting, printing, python Leave a comment

formatting long numbers as strings in python

August 16, 2022 by Magenaut

What is an easy way in Python to format integers into strings representing thousands with K, and millions with M, and leaving just couple digits after comma?

Categories Python, Q&A Tags formatting, integer, python, string Leave a comment

How can I break up this long line in Python?

August 16, 2022 by Magenaut

How would you go about formatting a long line such as this? I’d like to get it to no more than 80 characters wide:

Categories Python, Q&A Tags code-formatting, formatting, python Leave a comment

Python datetime formatting without zero-padding

August 16, 2022 by Magenaut

Is there a format for printing Python datetimes that won’t use zero-padding on dates and times?

Categories Python, Q&A Tags datetime, formatting, python, zero-pad Leave a comment
Older posts
Newer posts
← Previous Page1 Page2 Page3 Page4 Next →
  1. michealSmith07 on Is there a way to dynamically refresh the less command?August 21, 2022

    That is a very nice post. I like this post.

  2. anonymous on Fix libwacom9 dependency issue when upgrade DebianJune 27, 2022

    saved my day!! Thanks for the help…

  3. sreedhar on Fix libwacom9 dependency issue when upgrade DebianMay 10, 2022

    Thanks its working

  4. saintnick on Fix libwacom9 dependency issue when upgrade DebianMay 10, 2022

    remove libwacom2 worked for me as well

  5. ranafoul on Fix libwacom9 dependency issue when upgrade DebianApril 22, 2022

    apt remove libwacom2 helped on kali 2022.01. gr8

.net ajax asp.net asp.net-core asp.net-mvc asp.net-mvc-3 asp.net-mvc-4 asp.net-web-api bash c# command-line css custom-post-types custom-taxonomy dataframe dictionary django entity-framework functions gridview html iis javascript jquery json linux list matplotlib numpy pandas php plugin-development plugins posts python python-2.7 python-3.x security shell shell-script sql string vb.net webforms wp-query

© 2026 Magenaut • Built with GeneratePress