Recent Changes - Search:

Oktatás

* Programozás 1
  + feladatsor
  + GitHub oldal

* Szkriptnyelvek
  + feladatsor
  + quick link

Teaching

* Programming 1 (BI)
  ◇ exercises
  ◇ quick link

* Scripting Languages
  ◇ exercises
  ◇ quick link

teaching assets


Félévek

* aktuális (2023/24/2)
* archívum


Linkek

* kalendárium
   - munkaszüneti napok '20
* tételsorok
* jegyzetek
* szakdolgozat / PhD
* ösztöndíjak
* certificates
* C lang.
* C++
* C#
* Clojure
* D lang.
* Java
* Nim
* Scala


[ edit | logout ]
[ sandbox | passwd ]

20180407a

Zero fill a string from left

In Python:

>>> "2".zfill(4)
'0002'                     # fill with zeroes on the left, the width should be 4

>>> "123456789".zfill(4)
'123456789'                # never truncated

In C#:

csharp> "2".PadLeft(4, '0')        
"0002"                                 // fill with zeroes on the left, the width should be 4

csharp> "123456789".PadLeft(4, '0')
"123456789"                            // never truncated

Of course, instead of '0' you can specify any character. And if there is PadLeft, there is also PadRight.

Cloud City

  

Blogjaim, hobbi projektjeim

* The Ubuntu Incident
* Python Adventures
* @GitHub
* heroku
* extra
* haladó Python
* YouTube listák


Debrecen | la France


[ edit ]

Edit - History - Print *** Report - Recent Changes - Search
Page last modified on 2018 April 07, 12:09