About 50 results
Open links in new tab
  1. Convert integer to string in Python - Stack Overflow

    Jun 23, 2019 · Note: A variable in the format of string can be converted into an integer only if the variable is completely composed of numbers. In the same way, str () is used to convert an integer to …

  2. How do I check if a string represents a number (float or int)?

    A number, if the number is valid; A status code (e.g., via errno) or exception to show that no valid number could be parsed. C (as an example) hacks around this a number of ways. Python lays it out …

  3. python - How do I parse a string to a float or int? - Stack Overflow

    Dec 19, 2008 · For the reverse, see Convert integer to string in Python and Converting a float to a string without rounding it. Please instead use How can I read inputs as numbers? to close duplicate …

  4. python - How do I pad a string with zeros? - Stack Overflow

    What is the most pythonic way to pad a numeric string with zeroes to the left, i.e., so the numeric string has a specific length? str.zfill is specifically intended to do this:

  5. How to convert string to number in python? - Stack Overflow

    Dec 3, 2022 · How to convert string to number in python? Asked 3 years, 2 months ago Modified 3 years, 2 months ago Viewed 22k times

  6. python - Check if a string contains a number - Stack Overflow

    Nov 8, 2013 · I need to enter a string and check to see if it contains any numbers and if it does reject it. The function isdigit() only returns True if ALL of the characters are numbers.

  7. python - Best way to format integer as string with leading zeros ...

    The only time a difference is visible is in the .py source code. If you need to store information like "format this number with leading zeros until the hundreds place", integers alone cannot provide that - you …

  8. python - Display number with leading zeros - Stack Overflow

    str(number).rjust(string_width, fill_char) This way, the original string is returned unchanged if its length is greater than string_width. Example:

  9. How can I concatenate a string and a number in Python?

    Aug 8, 2011 · Since Python is a strongly typed language, concatenating a string and an integer, as you may do in Perl, makes no sense, because there's no defined way to "add" strings and numbers to …

  10. python - Count the number of occurrences of a character in a string ...

    How do I count the number of occurrences of a character in a string? e.g. 'a' appears in 'Mary had a little lamb' 4 times.